Skip to content

build: prepare for first PyPI release#50

Merged
MoAly98 merged 5 commits intomainfrom
deploy
Mar 26, 2026
Merged

build: prepare for first PyPI release#50
MoAly98 merged 5 commits intomainfrom
deploy

Conversation

@MoAly98
Copy link
Copy Markdown
Owner

@MoAly98 MoAly98 commented Mar 25, 2026

Summary

  • Clean up pyproject.toml: Python >=3.11, Alpha status, keywords, dependency version pins, coverage typo fix
  • Set ruff line-length to 120, remove cargo-culted ignores (E501, I002, EM101, PLC0415, RUF052), fix all resulting violations
  • Add py.typed marker for PEP 561 typed package support
  • Add CD workflow for PyPI publishing via trusted publishers (OIDC)
  • Track uv.lock in version control

Manual setup after merge

  1. Create PyPI trusted publisher: package everwillow, repo MoAly98/everwillow, workflow cd.yml, environment pypi
  2. Create GitHub environment pypi in repo Settings → Environments

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

The PR comprises widespread code formatting optimizations (collapsing multi-line expressions to single-line forms), adds from __future__ import annotations for postponed type evaluation across multiple modules, introduces a GitHub Actions CD workflow for automated PyPI publishing, updates pyproject.toml with dependency version constraints and Python 3.11+ support, and refactors error message handling to assign messages to variables before raising exceptions.

Changes

Cohort / File(s) Summary
CI/Build Configuration
.github/workflows/cd.yml, .gitignore, pyproject.toml
Added new GitHub Actions workflow for publishing to PyPI on release events; removed uv.lock from .gitignore; updated package metadata with Python 3.11 support, development status classifier, keywords field, and pinned dependency versions for jaxtyping, orbax-checkpoint, treescope, tqdm; reconfigured Ruff and coverage tool settings.
Future Annotations Imports
src/everwillow/_src/statelib/__init__.py, src/everwillow/hypotest/..., src/everwillow/parameters/bounds.py, src/everwillow/statelib/..., examples/model_1sig_2bkg_1nf_1ss_1ns/...
Added from __future__ import annotations to defer evaluation of type annotations at runtime across public and internal modules.
Inference Module Formatting
src/everwillow/_src/inference/fitting.py, src/everwillow/_src/inference/hypotest/distributions.py, src/everwillow/_src/inference/hypotest/test_statistics.py, src/everwillow/_src/inference/hypotest/toys.py, src/everwillow/_src/inference/hypotest/utils.py, src/everwillow/_src/inference/uncertainty.py
Refactored error message handling to assign exception messages to msg variable before raising; collapsed multi-line function calls, jit expressions, and dictionary comprehensions to single lines; updated docstring math formatting.
Parameters Module Formatting
src/everwillow/_src/parameters/transforms.py
Refactored validation error messages to use msg variable before raising; simplified multi-line f-strings for error construction into single-line forms; reflowed docstring text.
Statelib Module Formatting
src/everwillow/_src/statelib/meta.py, src/everwillow/_src/statelib/state.py
Collapsed multi-line jtu.tree_unflatten and State constructor calls into single-line expressions; simplified function signature formatting.
Example Files Formatting
docs/python/test_evermore_example.py, docs/python/test_pyhs3_example.py, examples/hgg_parametric/hgg_parametric.py, examples/model_1sig_2bkg_1nf_1ss_1ns/...
Collapsed multi-line method/function calls (scale_log_asymmetric, GenericFunction, fit, ifit, hist) into single lines; condensed dictionary/list comprehensions; added from __future__ import annotations to example modules.
Test File Formatting
tests/inference/hypotest/test_distributions.py, tests/inference/hypotest/test_results.py, tests/inference/hypotest/test_test_statistics.py, tests/inference/hypotest/test_upper_limit.py, tests/inference/hypotest/test_utils.py, tests/inference/test_fitting.py, tests/inference/test_uncertainty.py, tests/parameters/test_transforms.py
Simplified test method signatures, inlined function call arguments, collapsed multi-line patch, approx, and assertion expressions into single lines; refactored test helpers to use single-line BandValues/State constructions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • pfackeldey
  • maxgalli

Poem

🐰 From multi-line sprawl to single-line neat,
Future annotations make our types complete,
PyPI awaits with workflows so keen,
Dependencies pinned, a release machine,
Formatting hops from the carrot we eat! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'build: prepare for first PyPI release' accurately summarizes the main objective of this changeset, which adds a CI/CD workflow for publishing to PyPI, updates package metadata, and applies code formatting improvements in preparation for the first release.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch deploy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MoAly98 MoAly98 changed the title Deploy build: prepare for first PyPI release Mar 25, 2026
@MoAly98 MoAly98 requested a review from pfackeldey March 25, 2026 14:35
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
pyproject.toml (1)

116-118: Consider aligning mypy python_version with minimum supported Python.

The python_version = "3.13" in mypy config doesn't match requires-python = ">=3.11". This means mypy type-checks against Python 3.13 semantics, potentially missing compatibility issues with 3.11/3.12.

💡 Suggested change
 [tool.mypy]
 files = ["src", "tests"]
-python_version = "3.13"
+python_version = "3.11"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` around lines 116 - 118, The mypy configuration currently sets
python_version = "3.13" which diverges from the package's minimum supported
Python (requires-python = ">=3.11"); update the mypy setting to match the
minimum supported interpreter (e.g., change the mypy `python_version` value in
the [tool.mypy] section from "3.13" to "3.11") so type-checking uses Python 3.11
semantics and catches compatibility issues for supported versions.
src/everwillow/hypotest/upper_limit.py (1)

3-4: Consider whether stringified annotations are needed in re-export modules.

While this change is likely safe for function re-exports, adding from __future__ import annotations in a public API module means that any downstream code using typing.get_type_hints() on the imported functions must pass proper localns/globalns parameters to resolve the stringified annotations.

Consider whether this module actually benefits from PEP 563, or if it could be omitted here since:

  • The implementation module (_src.inference.hypotest.upper_limit) already has it
  • Re-export modules typically don't define new types, only import them
  • Removes one potential source of annotation resolution issues for users
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/everwillow/hypotest/upper_limit.py` around lines 3 - 4, The re-export
module contains "from __future__ import annotations" which stringifies type
annotations and can force callers of typing.get_type_hints() to supply
localns/globals; remove this future import from
src/everwillow/hypotest/upper_limit.py (leaving the implementation module
_src.inference.hypotest.upper_limit untouched) so the re-export does not
introduce PEP 563 behavior for downstream users who import the re-exported
functions/classes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Line 12: Update the mypy configuration's python_version to match the package
minimum by changing the mypy key python_version from "3.13" to "3.11" so it
aligns with the project requires-python = ">=3.11"; locate the mypy section in
pyproject.toml and edit the python_version entry (symbol: python_version) to
"3.11" to ensure type checking targets the minimum supported Python version
(referencing requires-python).

In `@src/everwillow/hypotest/toys.py`:
- Around line 3-4: Remove the future stringified-annotation import: delete the
line "from __future__ import annotations" from the re-export module
(src/everwillow/hypotest/toys.py) and from the implementation module where the
type hints must be evaluable (the hypotest toys implementation module), because
Equinox/equinox.Module needs real annotations for PyTree field registration;
ensure no other code relies on postponed evaluation (if needed, replace any
forward-reference strings with actual types or from typing import TYPE_CHECKING
guards) so that field introspection in Equinox works correctly.

---

Nitpick comments:
In `@pyproject.toml`:
- Around line 116-118: The mypy configuration currently sets python_version =
"3.13" which diverges from the package's minimum supported Python
(requires-python = ">=3.11"); update the mypy setting to match the minimum
supported interpreter (e.g., change the mypy `python_version` value in the
[tool.mypy] section from "3.13" to "3.11") so type-checking uses Python 3.11
semantics and catches compatibility issues for supported versions.

In `@src/everwillow/hypotest/upper_limit.py`:
- Around line 3-4: The re-export module contains "from __future__ import
annotations" which stringifies type annotations and can force callers of
typing.get_type_hints() to supply localns/globals; remove this future import
from src/everwillow/hypotest/upper_limit.py (leaving the implementation module
_src.inference.hypotest.upper_limit untouched) so the re-export does not
introduce PEP 563 behavior for downstream users who import the re-exported
functions/classes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e5597c1d-580f-43eb-93a7-0d98277c4331

📥 Commits

Reviewing files that changed from the base of the PR and between 99e6995 and 61bd6a6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (39)
  • .github/workflows/cd.yml
  • .gitignore
  • docs/python/test_evermore_example.py
  • docs/python/test_pyhs3_example.py
  • examples/hgg_parametric/hgg_parametric.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/compare.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/compare_ifit.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/evermore_model.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/model_config.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/pyhf_model.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/pyhs3_model.py
  • examples/model_1sig_2bkg_1nf_1ss_1ns/utils.py
  • pyproject.toml
  • src/everwillow/_src/inference/fitting.py
  • src/everwillow/_src/inference/hypotest/distributions.py
  • src/everwillow/_src/inference/hypotest/test_statistics.py
  • src/everwillow/_src/inference/hypotest/toys.py
  • src/everwillow/_src/inference/hypotest/utils.py
  • src/everwillow/_src/inference/uncertainty.py
  • src/everwillow/_src/parameters/transforms.py
  • src/everwillow/_src/statelib/__init__.py
  • src/everwillow/_src/statelib/meta.py
  • src/everwillow/_src/statelib/state.py
  • src/everwillow/hypotest/toys.py
  • src/everwillow/hypotest/upper_limit.py
  • src/everwillow/hypotest/utils.py
  • src/everwillow/parameters/bounds.py
  • src/everwillow/py.typed
  • src/everwillow/statelib/__init__.py
  • src/everwillow/statelib/state.py
  • src/everwillow/statelib/transform.py
  • tests/inference/hypotest/test_distributions.py
  • tests/inference/hypotest/test_results.py
  • tests/inference/hypotest/test_test_statistics.py
  • tests/inference/hypotest/test_upper_limit.py
  • tests/inference/hypotest/test_utils.py
  • tests/inference/test_fitting.py
  • tests/inference/test_uncertainty.py
  • tests/parameters/test_transforms.py
💤 Files with no reviewable changes (1)
  • .gitignore

Comment thread pyproject.toml
Comment thread src/everwillow/hypotest/toys.py
@pfackeldey
Copy link
Copy Markdown
Collaborator

@MoAly98 cd.yml and pyproject.toml look good 👍 I don't know why do you want to track uv.lock?

@MoAly98
Copy link
Copy Markdown
Owner Author

MoAly98 commented Mar 25, 2026

@MoAly98 cd.yml and pyproject.toml look good 👍 I don't know why do you want to track uv.lock?

@pfackeldey I have seen repos distirbuting that for reproducible installs from source

@MoAly98 MoAly98 merged commit 517efcb into main Mar 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants