Skip to content

Commit

Permalink
Make PythonPackages.get() more flexible to _/- (#10184)
Browse files Browse the repository at this point in the history
Basically the same thing we already do, but in reverse. Since we remain
very inconsistent about when we refer to a package with its dashes and
when we refer to it with its underscores because pip generally treats
the two as synonyms.
  • Loading branch information
jmsanders committed Oct 26, 2022
1 parent bd6e269 commit b5212c7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def get(cls, name: str) -> Optional[PythonPackage]:
# We're inconsistent about whether we use dashes or undrescores and we
# get away with it because pip converts all underscores to dashes. So
# mimic that behavior.
return cls.all.get(name) or cls.all.get(name.replace("_", "-"))
return (
cls.all.get(name)
or cls.all.get(name.replace("_", "-"))
or cls.all.get(name.replace("-", "_"))
)

@classmethod
def walk_dependencies(cls, requirement: Requirement) -> Set[PythonPackage]:
Expand Down

0 comments on commit b5212c7

Please sign in to comment.