Repository navigation
Conversation
| if platform.python_version().rstrip('+') not in self._metadata.requires_python: | ||
| if not self._metadata.requires_python.contains( | ||
| platform.python_version().rstrip('+'), prereleases=True | ||
| ): |
There was a problem hiding this comment.
I may be reading the packaging documentation wrong, but the default is prereleases=None and this is treated the same as prereleases=True (if this is not the case the documentation may require some clarification). Thus this change does not seem to be needed, namely setting prereleases = True can be simply dropped?
There was a problem hiding this comment.
Correct, but this behavior was changed (by me) in packaging 26.0 to correctly match the spec.
So you would need to set packaging >= 26.0 in your pyproject.toml, and then yes, you can remove the line self._metadata.requires_python.prereleases = True.
I can update this PR to do that if you prefer.
There was a problem hiding this comment.
Thanks for the explanation. I think the current approach is preferable.
dc84b4a to
391e91e
Compare
|
I took the freedom to extend the commit message and to apply some cosmetic fixes. @notatallshaw please have a look. |
391e91e to
9e80bd1
Compare
All looks fine to me. |
The packaging maintainers plan to deprecate mutability of packaging's core objects to improve performance and hashability. Avoid mutating the packaging.SpecifierSet object used to hold the requires-python specifier when matching against the current Python version.
9e80bd1 to
412e962
Compare
|
Thanks @notatallshaw |
I plan to deprecate mutability of
packaging's core objects to improve performance and hashability. This PR removes mutation of the project'srequires-pythonspecifier ahead of that change.A new
__replace__API will cover callers that need a modified copy in future versions of packaging. The interpreter check doesn't need a copy: it passesprereleases=Truetocontains(), keeping preview Python versions eligible without changing project metadata.