Skip to content

Commit

Permalink
Fix duplicate packages being listed in mypy entry of pre-commit config
Browse files Browse the repository at this point in the history
  • Loading branch information
randy-seng committed Oct 17, 2024
1 parent e6da5e1 commit e6f1e3e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions update_precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def __str__(self) -> str:
def __hash__(self) -> int:
return hash((self.name, self.version))

def __eq__(self, other: object) -> bool:
if not isinstance(other, Package):
return False
return (self.name, self.version) == (other.name, other.version)


class TypeStubPackage(Package):
@property
Expand Down Expand Up @@ -115,8 +120,10 @@ def parse_requirement(requirement_line: str) -> Package | None:
match = pattern.match(requirement_line)
if not match:
return None
package_name = match.group(CAPTURE_GROUP_PACKAGE)
package_version = match.group(CAPTURE_GROUP_VERSION)
package_name = match.group(CAPTURE_GROUP_PACKAGE).strip()
if package_version := match.group(CAPTURE_GROUP_VERSION):
package_version = package_version.strip()

return create_package(name=package_name, version=package_version)


Expand Down

0 comments on commit e6f1e3e

Please sign in to comment.