Skip to content

Commit

Permalink
feat: added some typing
Browse files Browse the repository at this point in the history
fix: corrected a regex

Signed-off-by: Paul Horton <phorton@sonatype.com>
  • Loading branch information
madpah committed Dec 17, 2021
1 parent 550f8af commit 169ff6e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions requirements/requirement.py
Expand Up @@ -13,7 +13,7 @@
VCS_SCHEMES_REGEX = r'|'.join([scheme.replace('+', r'\+') for scheme in VCS_SCHEMES])
VCS_REGEX = re.compile(
rf'^(?P<scheme>{VCS_SCHEMES_REGEX})://((?P<login>[^/@]+)@)?'
r'(?P<path>[^#@]+)@(?P<revision>[^#]+))?(#(?P<fragment>\S+))?'
r'(?P<path>[^#@]+)(@(?P<revision>[^#]+))?(#(?P<fragment>\S+))?'
)

# This matches just about everything
Expand Down Expand Up @@ -51,7 +51,7 @@ class Requirement(object):
(eg. "mymodule>1.5,<1.6" => [('>', '1.5'), ('<', '1.6')])
"""

def __init__(self, line):
def __init__(self, line: str) -> None:
# Do not call this private method
self.line = line
self.editable = False
Expand All @@ -65,13 +65,13 @@ def __init__(self, line):
self.revision = None
self.hash_name = None
self.hash = None
self.extras = []
self.specs = []
self.extras: list[str] = []
self.specs: list[str] = []

def __repr__(self):
def __repr__(self) -> str:
return '<Requirement: "{0}">'.format(self.line)

def __getitem__(self, key):
def __getitem__(self, key: str) -> str:
return getattr(self, key)

def __eq__(self, other):
Expand Down

0 comments on commit 169ff6e

Please sign in to comment.