Skip to content

Normalize case and make small changes in the reference implementation for dependency groups resolution#2045

Open
jonathandung wants to merge 1 commit into
pypa:mainfrom
jonathandung:main
Open

Normalize case and make small changes in the reference implementation for dependency groups resolution#2045
jonathandung wants to merge 1 commit into
pypa:mainfrom
jonathandung:main

Conversation

@jonathandung
Copy link
Copy Markdown

@jonathandung jonathandung commented May 12, 2026

raise TypeError("Dependency Groups table is not a dict")

->

raise TypeError("Dependency groups table is not a dict")
dependency_groups_raw = pyproject["dependency-groups"]
dependency_groups = _normalize_group_names(dependency_groups_raw)
print("\n".join(resolve(pyproject["dependency-groups"], sys.argv[1])))

->

dependency_groups_raw = pyproject["dependency-groups"]
dependency_groups = _normalize_group_names(dependency_groups_raw)
print("\n".join(resolve(dependency_groups_raw, sys.argv[1])))

📚 Documentation preview 📚: https://python-packaging-user-guide--2045.org.readthedocs.build/en/2045/

@webknjaz
Copy link
Copy Markdown
Member

@jonathandung motivation? Justification?

cc @sirosen

@jonathandung
Copy link
Copy Markdown
Author

For the first one, I notice that the last commit to this file 1700f85 changed dependency groups to lowercase where suitable, and I think this qualifies. For the second, it is simply strange to me that pyproject["dependency-groups"] was used rather than dependency_groups_raw which had just been defined as exactly that.

@sirosen
Copy link
Copy Markdown
Contributor

sirosen commented May 14, 2026

I have no strong feeling about the string in the TypeError. It's fine either way. The PEP was consistent about using Title Case, and the PyPUG docs are generally consistent about using lowercase. I would not bother changing it but I don't think it's a big enough deal to block the change over. (@jonathandung, I recommend removing that change, only because it may prevent this from getting merged, and my opinion is that the casing there is not as important as your other change.)

The other is a bugfix. Non-normalized names are being used by the example code, but resolution must use normalized names. I'm on my phone at the moment so I can't verify, but I'm pretty sure that is you try to resolve foo and your TOML data uses the name FOO, it will (incorrectly) fail.

@jonathandung
Copy link
Copy Markdown
Author

pyproject is an ordinary dictionary which is not modified between its lookups, so I don't really understand your mention about the resolution possibly failing. Can you please clarify? If there is a bug in my new version, the same bug must have existed in the old version. I was not aiming to fix a bug, but if that is indeed a bug, I am open to try and tackle it.

@sirosen
Copy link
Copy Markdown
Contributor

sirosen commented May 15, 2026

I was not aiming to fix a bug, but if that is indeed a bug, I am open to try and tackle it.

I'm saying you already did fix a bug! 😀 🎉

The current version fails on the following input:

[dependency-groups]
FOO = ["requests"]

If you try to resolve foo against this, it raises a LookupError because the code is accidentally using dependency_groups_raw, not the normalized version.

The code in the original reference implementation in the PEP text also has this bug, in very slightly different form. Out of scope for a change here, but worth noting.

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.

3 participants