You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed what seems to be an inconsistent normalisation when running the following:
$ pipxrun--pythonpython3.12--pip-run'packaging==24.1'# Python 3.12.7 (main, Oct 1 2024, 08:52:11) [GCC 9.4.0] on linux# Type "help", "copyright", "credits" or "license" for more information.>>>frompackaging.requirementsimportRequirement>>>req1=Requirement('mariadb>=1.0.1; extra == "mariadb_connector"')
>>>str(req1)
'mariadb>=1.0.1; extra == "mariadb-connector"'>>>req2=Requirement('mariadb>=1.0.1; python_version >= "3" and extra == "mariadb_connector"')
>>>str(req2)
'mariadb>=1.0.1; python_version >= "3" and extra == "mariadb_connector"'
Here for req1, Requirement.__str__ normalises the extra to mariadb-connector, in accordance to PEP 685.
But when there are other markers involved like in req2, it seems to preserve the original value without normalisation.
Is this behaviour expected? It looks a bit inconsistent to me.
Related to #644 (comment).
The text was updated successfully, but these errors were encountered:
abravalheri
changed the title
Possibly inconsistent extra normalisation in Requirement.__str__?
Inconsistent extra normalisation in Requirement.__str__Nov 4, 2024
$ pipxrun--pythonpython3.12--pip-run'packaging==24.2'# Python 3.12.7 (main, Oct 1 2024, 08:52:11) [GCC 9.4.0] on linux# Type "help", "copyright", "credits" or "license" for more information.>>>frompackaging.requirementsimportRequirement>>>req1=Requirement('mariadb>=1.0.1; extra == "mariadb_connector"')
>>>str(req1)
'mariadb>=1.0.1; extra == "mariadb-connector"'>>>req2=Requirement('mariadb>=1.0.1; python_version >= "3" and extra == "mariadb_connector"')
>>>str(req2)
'mariadb>=1.0.1; python_version >= "3" and extra == "mariadb_connector"'
I believe this normalisation in the environment markers are implied by PEP 685:
I noticed what seems to be an inconsistent normalisation when running the following:
Here for
req1
,Requirement.__str__
normalises the extra tomariadb-connector
, in accordance to PEP 685.But when there are other markers involved like in
req2
, it seems to preserve the original value without normalisation.Is this behaviour expected? It looks a bit inconsistent to me.
Related to #644 (comment).
The text was updated successfully, but these errors were encountered: