Skip to content

Commit

Permalink
refactor: str.startswith usage is simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
myhailo-chernyshov-rg committed Dec 19, 2024
1 parent 5349f35 commit 80ed18c
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ def is_requirement(line):
line = line.strip()

# Skip blank lines, comments, and editable installs
return not (
line == ''
or line.startswith('-r')
or line.startswith('#')
or line.startswith('-e')
or line.startswith('git+')
or line.startswith('-c')
)
return bool(line) and not line.startswith(("-r", "#", "-e", "git+", "-c"))


def load_requirements(*requirements_paths):
Expand All @@ -43,7 +36,7 @@ def load_requirements(*requirements_paths):
requirements = set()
for path in requirements_paths:
requirements.update(
line.split('#')[0].strip() for line in open(path).readlines()
line.split("#")[0].strip() for line in open(path).readlines()
if is_requirement(line)
)
return list(requirements)

0 comments on commit 80ed18c

Please sign in to comment.