From 6e5509ef0a40026f6ce6a4fc8c69d8e127e9256a Mon Sep 17 00:00:00 2001 From: Myhailo Chernyshov Date: Thu, 19 Dec 2024 08:42:50 +0200 Subject: [PATCH] refactor: `str.startswith` usage is simplified --- setup.py | 2 +- utils.py | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index b8b1705..0df0a5f 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ ], description=("Command line tool, that converts Common Cartridge " "courses to Open edX Studio imports."), entry_points={"console_scripts": ["cc2olx=cc2olx.main:main"]}, - install_requires=load_requirements("requirements/base.txt"), + install_requires=load_requirements("requirements/base.in"), license="GNU Affero General Public License", long_description=readme, include_package_data=True, diff --git a/utils.py b/utils.py index a3fc4c8..5f1f1e5 100644 --- a/utils.py +++ b/utils.py @@ -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): @@ -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)