8000 Possible improvements to dependency groups · Issue #3594 · urllib3/urllib3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Possible improvements to dependency groups #3594

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

Open
musicinmybrain opened this issue Apr 15, 2025 · 0 comments
Open

Possible improvements to dependency groups #3594

musicinmybrain opened this issue Apr 15, 2025 · 0 comments

Comments

@musicinmybrain
Copy link

Context

There are two things I notice about the current dependency groups.


First, there is a lot of repetition between dev and mypy:

urllib3/pyproject.toml

Lines 58 to 94 in 910f031

dev = [
"anyio[trio]>=4.8.0",
"build>=1.2.2.post1",
"coverage>=7.8.0",
"cryptography>=44.0.2",
"h2>=4.1.0",
"httpx>=0.28.1",
"hypercorn",
"idna>=3.10",
"pyopenssl>=25.0.0",
"pysocks>=1.7.1",
"pytest>=8.3.4",
"pytest-memray==1.7.0 ; python_full_version < '3.14' and implementation_name == 'cpython' and sys_platform != 'win32'",
"pytest-socket>=0.7.0",
"pytest-timeout>=2.3.1",
"quart>=0.20.0",
"quart-trio>=0.12.0",
"towncrier>=24.8.0",
"trustme>=1.2.1",
"trio>=0.27.0",
]
mypy = [
"anyio[trio]>=4.8.0",
"cryptography>=44.0.2",
"httpx>=0.28.1",
"hypercorn>=0.15.0",
"idna>=3.10",
"mypy>=1.14.1",
"pytest>=8.3.4",
"quart>=0.20.0",
"quart-trio>=0.12.0",
"trio>=0.27.0",
"trustme>=1.2.1",
"types-requests>=2.32.0.20241016",
"nox>=2024.10.9",
"zstandard>=0.23.0",
]

I am not sure exactly what to say that the common dependencies represent, but if we could figure out something sensible to call them, we could represent them in their own dependency group:

some_other_group = [
    "anyio[trio]>=4.8.0",
    "cryptography>=44.0.2",
    "httpx>=0.28.1",
    "hypercorn>=0.15.0",  # dev lacks the version bound; both are affected by tool.uv.sources.hypercorn
    "idna>=3.10",
    "pytest>=8.3.4",
    "quart>=0.20.0",
    "quart-trio>=0.12.0",
    "trio>=0.27.0",
    "trustme>=1.2.1",
]

and then use Dependency Group Includes:

dev = [
    "build>=1.2.2.post1",
    "coverage>=7.8.0",
    "h2>=4.1.0",
    "pyopenssl>=25.0.0",
    "pysocks>=1.7.1",
    "pytest-memray==1.7.0 ; python_full_version < '3.14' and implementation_name == 'cpython' and sys_platform != 'win32'",
    "pytest-socket>=0.7.0",
    "pytest-timeout>=2.3.1",
    "towncrier>=24.8.0",
    {include-group = "some_other_group"},
]
mypy = [
    "mypy>=1.14.1",
    "types-requests>=2.32.0.20241016",
    "nox>=2024.10.9",
    "zstandard>=0.23.0",
    {include-group = "some_other_group"},
]

Second, in Fedora we really benefit from dependency groups because we can use them to generate build-time requirements for running the tests rather than manually enumerating them; see discussion in https://src.fedoraproject.org/rpms/python-urllib3/pull-request/44.

However, we really just want the dependencies for running the tests, without profilers (like pytest-memray), coverage analysis (coverage), or tools for maintainer tasks (build, towncrier). It would be really helpful if there were a dependency group (test, presumably) that just listed test dependencies. Even if you decided not to split out coverage and profiling dependencies, and even if we still had to patch out a couple of unwanted dependencies, this would be a much more useful starting point than the dev group is.

If you decide to do this, the “dependency group includes” technique demonstrated above would make it easy to include a new test group in the dev group, so dev could still install “everything.”

Alternatives

For the first suggestion, repetition of dependency specifications seems to be more of an inconvenience for upstream maintainers than it is for downstream packagers and users. The alternative is the status quo, and it’s generally adequate.

For the second suggestion, one alternative for the Fedora package is to manually list BuildRequires for testing, as we did prior to 2.4.0. This is acceptable; it requires some care to make sure that the manual list remains synchronized with the actual upstream dependencies. The other alternative is to patch the contents of the dev dependency group – using sed or a TOML-specific patching tool – before using it to generate BuildRequires, as currently proposed in https://src.fedoraproject.org/rpms/python-urllib3/pull-request/44. This is viable, but the less patching we can do, the less trouble it is, and the fewer errors we are likely to make.

Duplicate

I did not find any similar requests.

Contribution

Would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

Yes, I would be willing to submit a PR if a rough consensus on design and nomenclature emerges.

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

No branches or pull requests

1 participant
0