Skip to content

Conversation

@bellini666
Copy link
Member

@bellini666 bellini666 commented Dec 29, 2025

modern-problems-funny-gif-gif-by-moodman

Summary by Sourcery

Migrate the project’s packaging, dependency management, and automation from Poetry to uv and Hatch, updating local development, CI, and release workflows accordingly.

Build:

  • Replace Poetry build backend with Hatchling and configure wheel/sdist targets in pyproject.toml.
  • Add uv tool configuration with default dependency groups and adjust dependency group declarations for uv compatibility.
  • Introduce uv.lock to the repository for deterministic uv-based dependency resolution.

CI:

  • Update all GitHub Actions workflows to install and use uv for dependency management, testing, linting, benchmarks, e2e tests, and federation compatibility checks, including caching based on uv.lock.
  • Refactor release and pre-release workflows to build and publish distributions using uv and UV_PUBLISH_TOKEN instead of Poetry.
  • Adjust Windows and matrix test jobs to run nox, pytest, mypy, coverage, and other tooling via uv rather than Poetry.

Documentation:

  • Update CONTRIBUTING instructions to require uv instead of Poetry and to use uv-based commands for installing dependencies, running tests, and setting up pre-commit hooks.

Tests:

  • Refactor nox sessions to install project and test dependencies via uv sync and standard nox session.install calls instead of Poetry-driven environments and private session internals.

Chores:

  • Remove Poetry-specific tooling and configuration (including nox-poetry usage and Poetry references in workflows) in favor of a uv-centric setup.

@bellini666 bellini666 requested a review from patrick91 December 29, 2025 16:28
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 29, 2025

Reviewer's Guide

Replaces Poetry with uv as the primary packaging and environment tool, switching build backend to Hatchling, updating Nox sessions and CI workflows to use uv for dependency management, lockfile, builds, and publishing, and adjusting contributor docs accordingly.

File-Level Changes

Change Details Files
Switch project packaging and dependency metadata from Poetry to uv with Hatchling backend.
  • Convert dev and integrations dependency group entries from Poetry constraint syntax to plain PEP 508 requirement strings compatible with uv.
  • Remove [tool.poetry] configuration, replacing it with [tool.uv] default-groups and Hatch build configuration blocks for wheel and sdist packaging.
  • Change build-system configuration to require hatchling and use hatchling.build as the build backend.
  • Add uv.lock to the repo as the new lockfile.
pyproject.toml
uv.lock
Refactor Nox sessions to install dependencies via uv and standard nox.Session APIs instead of Poetry and private session internals.
  • Replace bare @session decorators with @nox.session and type the session parameter as nox.Session throughout.
  • Replace session.run_always('poetry', 'install', ...) with session.run_install('uv', 'sync', ...) configured to install into the session virtualenv and optionally exclude the integrations group.
  • Stop using session._session.install and instead call session.install for additional per-session dependencies like django, starlette, pydantic, pytest plugins, and type checkers.
noxfile.py
Update CI workflows to use uv for environment management, dependency installation, testing, linting, e2e, and federation compatibility jobs.
  • Replace Poetry installation and usage with uv setup (astral-sh/setup-uv@v5), uv sync, and uv run in test, lint, Windows tests, e2e, codeflash, and federation compatibility workflows.
  • Update workflow triggers and caches to track uv.lock instead of poetry.lock where relevant.
  • Adjust commands like pytest, mypy, coverage, and codeflash to be invoked via uv run instead of poetry run or plain tools.
  • Use uv for Python installation in certain jobs (e.g., uv python install) where previously actions/setup-python managed the version.
.github/workflows/test.yml
.github/workflows/release.yml
.github/workflows/pre-release-pr.yml
.github/workflows/e2e-tests.yml
.github/workflows/codeflash.yaml
.github/workflows/federation-compatibility.yml
Migrate release and pre-release automation from Poetry to uv-based build and publish flows.
  • Replace pip+Poetry based tool installation with uv pip install --system for githubrelease, autopub, httpx, and tweepy.
  • Switch environment variables from POETRY_PYPI_TOKEN_PYPI to UV_PUBLISH_TOKEN for publishing to PyPI.
  • Replace poetry build/publish commands with uv build and uv publish, and adjust version bumping logic to manipulate pyproject.toml directly instead of using poetry version.
  • Update sample install instructions in PR comments from poetry add to uv add.
.github/workflows/release.yml
.github/workflows/pre-release-pr.yml
Update contributor documentation to describe uv-based local development workflow instead of Poetry.
  • Replace instructions that require Poetry with references to uv and its documentation.
  • Update example commands for installing dependencies, running tests, running mypy, and installing pre-commit hooks to use uv sync and uv run ... instead of poetry install/poetry run ....
CONTRIBUTING.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@botberry
Copy link
Member

botberry commented Dec 29, 2025

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

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:

🆕 Release (next) is out! Thanks to @_bellini666 for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile Summary

This 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:

  • Replaced Poetry with uv for dependency management
  • Switched build backend from poetry.core.masonry.api to hatchling.build
  • Updated noxfile.py to use nox.Session instead of nox_poetry.Session and use uv sync with UV_PROJECT_ENVIRONMENT
  • Migrated all GitHub workflows to use astral-sh/setup-uv@v5 and uv commands
  • Updated documentation in CONTRIBUTING.md to reference uv instead of Poetry
  • Removed Poetry-specific dependencies like nox-poetry, poetry-plugin-export, and urllib3 (<2) workaround

Issue Found:

  • The py.typed marker file is not explicitly included in the new hatchling build configuration, which may break type checking support for downstream users

Confidence Score: 4/5

  • This PR is mostly safe to merge with one critical issue that needs attention
  • The migration from Poetry to uv is comprehensive and well-executed across all files. However, the missing py.typed file in the build configuration is a critical issue that would break type checking support for downstream users who depend on this library. Once this is fixed, the PR would be safe to merge.
  • Pay close attention to pyproject.toml - the build configuration is missing the py.typed marker file which is required for PEP 561 type checking support

Important Files Changed

Filename Overview
pyproject.toml Migrated from Poetry to uv with hatchling as build backend; removed poetry-specific dependencies
noxfile.py Updated to use uv for dependency management instead of poetry-nox; clean migration
.github/workflows/test.yml Migrated CI to use uv for dependency installation and test execution
.github/workflows/release.yml Updated release workflow to use uv for building and publishing packages

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Edit Code Review Agent Settings | Greptile

@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.39%. Comparing base (4d2881b) to head (539a999).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@botberry
Copy link
Member

botberry commented Dec 29, 2025

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🔲
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

@bellini666 bellini666 force-pushed the feat/poetry-to-uv branch 2 times, most recently from 9c80e2c to d5220c8 Compare December 29, 2025 16:55
@patrick91
Copy link
Member

For this we need to also migrate to autopub beta :)

patrick91/rich-toolkit@fff431e

Like I did here, maybe we can pair on it? 😊

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 29, 2025

CodSpeed Performance Report

Merging #4082 will improve performance by 40.07%

Comparing feat/poetry-to-uv (539a999) with main (4d2881b)

Summary

⚡ 28 improvements

Benchmarks breakdown

Benchmark BASE HEAD Efficiency
test_execute_with_many_fields_and_directives 43.3 ms 31.4 ms +38.07%
test_execute[with_resolveextension-items_10000] 1.9 s 1.5 s +30.54%
test_convert_argument_large_list[262144] 2.4 ms 2.2 ms +10.57%
test_execute[with_simpleextension-items_10000] 635 ms 462.8 ms +37.2%
test_interface_performance[4096] 68.5 ms 51.1 ms +34.06%
test_convert_argument_large_list[65536] 635.4 µs 570.7 µs +11.35%
test_convert_argument_large_list[1048576] 9.4 ms 8.5 ms +10.37%
test_interface_performance[1] 59.7 ms 43.7 ms +36.5%
test_interface_performance[16] 59.6 ms 43.8 ms +36.28%
test_convert_argument_large_list[16384] 207.9 µs 183.9 µs +13.09%
test_subscription 217.4 ms 155.2 ms +40.07%
test_convert_argument_large_list[4194304] 37.5 ms 34 ms +10.32%
test_stadium[seats_per_row_250] 6.7 s 4.8 s +40.03%
test_execute[with_no_extensions-items_1000] 67.7 ms 49.3 ms +37.36%
test_subscription_long_run[1000] 180.8 ms 133.3 ms +35.67%
test_stadium[seats_per_row_500] 13.3 s 9.5 s +39.97%
test_execute_generic_input 498.5 ms 363.6 ms +37.11%
test_execute_complex_schema[50] 4 s 2.9 s +38.44%
test_execute[with_simpleextension-items_1000] 67.9 ms 49.4 ms +37.42%
test_execute[with_no_extensions-items_10000] 631.2 ms 459.6 ms +37.33%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

uv run automatically syncs the environment with the lockfile, reverting
any manually installed packages like graphql-core==3.3.0a9 which is
required for incremental execution in the E2E tests.

Using --no-sync prevents this automatic sync behavior.
Same issue as e2e-tests: uv run reverts pydantic to v2 from lockfile
after manually installing pydantic==1.10 for compatibility.
FastAPI 0.128.0 (in uv.lock) requires Pydantic v2, so we can no longer
downgrade to pydantic==1.10. The original comment about starlette
compatibility is outdated.
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.

4 participants