feat(markers): support 'extras' and 'dependency_groups' markers#888
feat(markers): support 'extras' and 'dependency_groups' markers#888brettcannon merged 10 commits intopypa:mainfrom
Conversation
Signed-off-by: Frost Ming <[email protected]>
Signed-off-by: Frost Ming <[email protected]>
5af59cc to
200c455
Compare
Signed-off-by: Frost Ming <[email protected]>
|
The PR LGTM (and thanks, @frostming !), but since @pradyunsg wrote most of the code being changed I want to give him a chance to do a review if he has the time. If not I will merge this in about a week. |
src/packaging/markers.py
Outdated
| """ | ||
| current_environment = cast("dict[str, str]", default_environment()) | ||
| current_environment["extra"] = "" | ||
| current_environment.update(extra="", extras=set(), dependency_groups=set()) |
There was a problem hiding this comment.
We should not be setting these in the evaluation environments unconditionally, since that would allow packages to use the extras and dependency_groups marker variables in regular dependency declarations (outside of the context of a lockfile).
There was a problem hiding this comment.
This would make it ~impossible for downstream tools to implement the following behaviour from PEP 751's specification update:
Outside of the context of lock files, these two variables should result in an error like all other unknown variables.
There was a problem hiding this comment.
It would be good to add an explicit test for the unknown variable error case that this pertains to.
There was a problem hiding this comment.
Outside of the context of lock files, these two variables should result in an error like all other unknown variables.
But other unknown markers are thrown as InvalidMarker errors during the parse phase. Should we, and can we keep consistent for extras? That may require a different version of parsing function, possibly with a flag
There was a problem hiding this comment.
I made it a "should" statement for a reason. We could add a flag to evaluate() to specify the context and also clean things up for extra while we are at it, otherwise there's precedent of this code being sloppy/permissive in what it accepts.
There was a problem hiding this comment.
@brettcannon thanks for the clarification, not sure if I interpret your feedback correctly
There was a problem hiding this comment.
What I was thinking was instead of a for_lock argument, we have a context argument. That would take an enum that specified under what context the marker was being evaluated. We could have metadata which matches what it does now where extra is always set (and would be the default). We could have lock_file which doesn't have extra but has extras and dependency_groups always set. And then we could have requirement which has none of extra, extras, or dependency_groups automatically set.
FYI I'm not attached to any of these names.
There was a problem hiding this comment.
@pradyunsg does the approach Frost took work for you (it does for me)?
Signed-off-by: Frost Ming <[email protected]>
Signed-off-by: Frost Ming <[email protected]>
8fbf371 to
28a9c05
Compare
Signed-off-by: Frost Ming <[email protected]>
28a9c05 to
6f37ebf
Compare
brettcannon
left a comment
There was a problem hiding this comment.
Just a docstring change and docs will need updating.
Co-authored-by: Brett Cannon <[email protected]>
Signed-off-by: Frost Ming <[email protected]>
brettcannon
left a comment
There was a problem hiding this comment.
I think
Lines 61 to 74 in e624d8e
|
FYI linting failed. |
Signed-off-by: Frost Ming <[email protected]>
|
LGTM! We will give @pradyunsg until next week to weigh in, else I will merge this. |
pradyunsg
left a comment
There was a problem hiding this comment.
Let's do this! Thanks @frostming!
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [packaging](https://github.com/pypa/packaging) | project.dependencies | major | `==24.2` -> `==25.0` | --- ### Release Notes <details> <summary>pypa/packaging (packaging)</summary> ### [`v25.0`](https://github.com/pypa/packaging/releases/tag/25.0) [Compare Source](pypa/packaging@24.2...25.0) #### What's Changed - Re-add a test for Unicode file name parsing by [@​Siddhesh-Agarwal](https://github.com/Siddhesh-Agarwal) in pypa/packaging#863 - Upgrade to ruff 0.9.1 by [@​DimitriPapadopoulos](https://github.com/DimitriPapadopoulos) in pypa/packaging#865 - Add support for PEP 738 Android tags by [@​mhsmith](https://github.com/mhsmith) in pypa/packaging#880 - feat(markers): support 'extras' and 'dependency_groups' markers by [@​frostming](https://github.com/frostming) in pypa/packaging#888 #### New Contributors - [@​Siddhesh-Agarwal](https://github.com/Siddhesh-Agarwal) made their first contribution in pypa/packaging#863 - [@​mhsmith](https://github.com/mhsmith) made their first contribution in pypa/packaging#880 - [@​frostming](https://github.com/frostming) made their first contribution in pypa/packaging#888 **Full Changelog**: pypa/packaging@24.2...25.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yNTEuMCIsInVwZGF0ZWRJblZlciI6IjM5LjI1MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==--> Reviewed-on: https://git.tainton.uk/repos/pypilot/pulls/329 Reviewed-by: Luke Tainton <[email protected]> Co-authored-by: Renovate [BOT] <[email protected]> Co-committed-by: Renovate [BOT] <[email protected]>
Signed-off-by: Frost Ming [email protected]
Resolve #885