Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
metadata(name).json["keywords"]returns one item, the whole header, for distributions built by current backends. Core Metadata separates keywords with commas and setuptools writes them that way, butjsonsplits the field on whitespace only. With pytest 9.0.2 installed:black 26.10.1 and urllib3 2.7.0 behave the same way.
pip inspect, which emits the same PEP 566 JSON form, reports['test', 'unittest']for that install. A keyword that contains a space is split in the wrong place:Keywords: sample package,toolbecomes['sample', 'package,tool'], andsample, packagebecomes['sample,', 'package'].PEP 566 says to split on whitespace, but the Core Metadata specification defines Keywords as comma-separated, and notes that the earlier space-separated example never matched what distutils and setuptools wrote.
jsonnow splits on commas when the value contains one and on whitespace otherwise, which is also the rule pip uses. Space-separated values such as Pygments'syntax highlightinggive the same result as before. The stdlibimportlib.metadata(Python 3.13.18 here) has the same behavior today.test_as_json_comma_separated_keywordscoverssample,package,sample, packageandsample package,tool. All three subtests fail on main, for example withassert ['sample,package'] == ['sample', 'package']. The full suite passes (275 passed, 1 skipped) on Python 3.12.3 with thetest,check,cover,enablerandtypeextras, which run the ruff, ruff format and mypy checks. I also comparedjson["keywords"]withpip inspectfor black, pytest, urllib3 and Pygments before and after the change. I did not test other Python versions, Windows or macOS, or the CPython copy of the module.