-
-
Notifications
You must be signed in to change notification settings - Fork 607
feat: move from poetry to uv #4082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideMigrate the project from Poetry to a uv + Hatchling toolchain for packaging, dependency management, and CI/release workflows, while cleaning up Poetry-specific tooling and making tests and documentation uv-aware. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- The repeated
session.run_install("uv", "sync", ...)blocks across many nox sessions could be extracted into a small helper (e.g._sync_project(session, no_group_integrations: bool = True)) to avoid duplication and keep the sync flags/env consistent in one place. - In
pre-release-pr.yml, the version bump logic usinggrep/sedonpyproject.tomlassumes a singleversion =line and simple formatting; consider switching to a small Python/TOML snippet to read/update the version more robustly if the file structure changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The repeated `session.run_install("uv", "sync", ...)` blocks across many nox sessions could be extracted into a small helper (e.g. `_sync_project(session, no_group_integrations: bool = True)`) to avoid duplication and keep the sync flags/env consistent in one place.
- In `pre-release-pr.yml`, the version bump logic using `grep`/`sed` on `pyproject.toml` assumes a single `version =` line and simple formatting; consider switching to a small Python/TOML snippet to read/update the version more robustly if the file structure changes.
## Individual Comments
### Comment 1
<location> `pyproject.toml:142-143` </location>
<code_context>
+[tool.hatch.build.targets.wheel]
+packages = ["strawberry"]
+
+[tool.hatch.build.targets.sdist]
+include = ["/strawberry"]
[tool.pytest.ini_options]
</code_context>
<issue_to_address>
**issue (bug_risk):** The sdist `include` pattern is likely too restrictive and the leading `/` may prevent matching, which can produce a broken source distribution.
With hatch, `include` paths are relative to the project root, so `"/strawberry"` likely matches nothing. Also, limiting the sdist to only the `strawberry` directory will typically omit required files like `pyproject.toml`, README, and license, leading to an incomplete sdist on PyPI.
Either remove the `[tool.hatch.build.targets.sdist]` override to rely on hatch’s defaults, or switch to a relative pattern and explicitly include required files, for example:
```toml
[tool.hatch.build.targets.sdist]
include = [
"strawberry",
"pyproject.toml",
"README*",
"LICENSE*",
]
```
and drop the leading `/` so hatch can resolve the paths correctly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Hi, thanks for contributing to Strawberry 🍓! We noticed that this PR is missing a So as soon as this PR is merged, a release will be made 🚀. Here's an example of Release type: patch
Description of the changes, ideally with some examples, if adding a new feature.Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :) Here's the tweet text: |
Greptile SummaryThis PR migrates the project's dependency management and build system from Poetry to uv with hatchling as the build backend. The migration is comprehensive and well-executed across all workflows and documentation. Key Changes:
Issue Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant UV as uv Tool
participant Nox as Nox Sessions
participant CI as GitHub Actions
participant PyPI as PyPI Registry
Dev->>UV: uv sync
UV->>UV: Read pyproject.toml + uv.lock
UV->>UV: Install dev + integrations groups
Dev->>Nox: uv run nox -t tests
Nox->>UV: session.run_install("uv", "sync")
UV->>Nox: Install dependencies to virtualenv
Nox->>Nox: Run pytest with test matrix
CI->>CI: Trigger on push/PR
CI->>UV: Install uv via setup-uv@v5
CI->>UV: uv sync (with cache)
UV->>CI: Dependencies installed
CI->>Nox: uv run nox (test matrix)
Nox->>CI: Test results
CI->>UV: uv build (on release)
UV->>UV: Build wheel + sdist via hatchling
CI->>PyPI: uv publish
PyPI->>PyPI: Package published
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 files reviewed, 1 comment
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4082 +/- ##
==========================================
+ Coverage 94.22% 94.39% +0.16%
==========================================
Files 540 540
Lines 35499 35544 +45
Branches 1876 1881 +5
==========================================
+ Hits 33449 33550 +101
+ Misses 1739 1703 -36
+ Partials 311 291 -20 🚀 New features to boost your workflow:
|
142c3c7 to
036c926
Compare
Apollo Federation Subgraph Compatibility Results
Learn more: |
9c80e2c to
d5220c8
Compare
|
For this we need to also migrate to autopub beta :) patrick91/rich-toolkit@fff431e Like I did here, maybe we can pair on it? 😊 |
4e6cd13 to
dd8330c
Compare
539a999 to
1bf5370
Compare
1bf5370 to
fd1f86e
Compare
|
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- In the pre-release workflow, the version bump is implemented via a
sedonpyproject.toml; consider using a small Python snippet (e.g. viauv run python -c ...) to parse and update TOML safely to avoid edge cases with formatting or multipleversion =occurrences. - The new
_encode_multipart_formdatahelper intests/http/test_upload.pylargely duplicatesurllib3’s implementation; if the goal is to avoid the dependency, it might be worth extracting this helper into a small shared test utility module to keep tests cleaner and make future adjustments easier. - Several workflows repeat the
uvx --from autopub==1.0.0a55 --with pygithub autopubinvocation; you’ve already introducedAUTOPUB_CMDinpre-release-pr.yml—consider using a similar environment variable or composite action in other workflows to centralize the autopub invocation and make future upgrades easier.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the pre-release workflow, the version bump is implemented via a `sed` on `pyproject.toml`; consider using a small Python snippet (e.g. via `uv run python -c ...`) to parse and update TOML safely to avoid edge cases with formatting or multiple `version =` occurrences.
- The new `_encode_multipart_formdata` helper in `tests/http/test_upload.py` largely duplicates `urllib3`’s implementation; if the goal is to avoid the dependency, it might be worth extracting this helper into a small shared test utility module to keep tests cleaner and make future adjustments easier.
- Several workflows repeat the `uvx --from autopub==1.0.0a55 --with pygithub autopub` invocation; you’ve already introduced `AUTOPUB_CMD` in `pre-release-pr.yml`—consider using a similar environment variable or composite action in other workflows to centralize the autopub invocation and make future upgrades easier.
## Individual Comments
### Comment 1
<location> `.github/workflows/pre-release-pr.yml:74-81` </location>
<code_context>
- echo "version=$(poetry version -s)" >> $GITHUB_OUTPUT
+ $AUTOPUB_CMD prepare
+ # Get current version and append dev timestamp
+ CURRENT_VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)
+ DEV_VERSION="${CURRENT_VERSION}.dev.$(date '+%s')"
+ sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${DEV_VERSION}\"/" pyproject.toml
</code_context>
<issue_to_address>
**suggestion:** The version extraction in the pre-release workflow is brittle and could match unintended lines.
Using `grep 'version = '` and `cut` assumes the first matching line is the project version and that it always appears as `version = "..."`. This is fragile if another section defines `version =` or the formatting changes. Consider parsing the TOML directly (e.g. via `python -c 'import tomllib, pathlib; print(tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]["version"])'`) or at least restricting the search to the `[project]` section to make the workflow more robust.
```suggestion
$AUTOPUB_CMD prepare
# Get current version from [project] using tomllib and append dev timestamp
CURRENT_VERSION=$(python - << 'PY'
import tomllib
from pathlib import Path
data = tomllib.loads(Path("pyproject.toml").read_text())
print(data["project"]["version"])
PY
)
DEV_VERSION="${CURRENT_VERSION}.dev.$(date '+%s')"
sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${DEV_VERSION}\"/" pyproject.toml
$AUTOPUB_CMD build
uv publish
echo "version=${DEV_VERSION}" >> $GITHUB_OUTPUT
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
18585b7 to
3fd608c
Compare
3fd608c to
097aa56
Compare
Summary by Sourcery
Switch project tooling and workflows from Poetry to uv and hatchling, including releases, CI, local development, and containers.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Deployment:
Documentation:
Tests:
Chores: