use packaging.utils.canonicalize_name()#6022
use packaging.utils.canonicalize_name()#6022neersighted merged 1 commit intopython-poetry:masterfrom
Conversation
739b961 to
6ba31f6
Compare
neersighted
left a comment
There was a problem hiding this comment.
This LGTM. However, I wonder if it makes sense to re-export the method in poetry-core? Given your observations about alignment of the two projects, I feel like it might be good to ensure the same code is always used in the case of a packaging version mismatch.
This seems excessive to me. Any change to this method in This method hasn't been changed (bar type annotations) since introduction at pypa/packaging#60, and I don't expect that it ever will be. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
poetrycurrently has two different versions ofcanonicalize_name()floating around, which is slightly absurd - and what's worse, they don't even agree.Since python-poetry/poetry-core#328,
poetry-corehas an implementation that agrees with the implementation inpackaging- butpoetryhas its own implementation that continues to disagree with that. Sometimespoetryuses one of these, and sometimes the other.Let's treat the version from
packagingas the canonicalcanonicalize_name(), and get rid of both of the re-implementations.I don't know that this fixes - or breaks! - anything in particular; the unit tests don't detect a difference. But two differing implementations is surely an accident waiting to happen.
Aside from being one-true-implementation, a potential advantage of the
packagingversion is that it returns aNormalizedName: which is a newtype around string, rather than a plain string. That opens the door to future work in which the typechecker can verify that places which expect canonicalized names do indeed get them.(Will follow up in
poetry-core, but this one will need merging first sincepoetrysometimes uses thepoetry-coreversion).