diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright (C) 2015-2020 The Software Heritage developers +# Copyright (C) 2015-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -17,22 +17,23 @@ long_description = f.read() -def parse_requirements(name=None): - if name: - reqf = "requirements-%s.txt" % name - else: - reqf = "requirements.txt" - +def parse_requirements(*names): requirements = [] - if not path.exists(reqf): - return requirements + for name in names: + if name: + reqf = "requirements-%s.txt" % name + else: + reqf = "requirements.txt" + + if not path.exists(reqf): + return requirements - with open(reqf) as f: - for line in f.readlines(): - line = line.strip() - if not line or line.startswith("#"): - continue - requirements.append(line) + with open(reqf) as f: + for line in f.readlines(): + line = line.strip() + if not line or line.startswith("#"): + continue + requirements.append(line) return requirements @@ -48,12 +49,12 @@ author_email="swh-devel@inria.fr", url="https://forge.softwareheritage.org/diffusion/DGRPH", packages=find_packages(), - install_requires=parse_requirements() + parse_requirements("swh"), + install_requires=parse_requirements(None, "swh"), tests_require=parse_requirements("test"), setup_requires=["setuptools-scm"], use_scm_version=True, extras_require={ - "testing": parse_requirements("test"), + "testing": parse_requirements("luigi", "test"), "luigi": parse_requirements("luigi"), }, include_package_data=True, diff --git a/swh/graph/luigi/origin_contributors.py b/swh/graph/luigi/origin_contributors.py --- a/swh/graph/luigi/origin_contributors.py +++ b/swh/graph/luigi/origin_contributors.py @@ -14,7 +14,7 @@ # WARNING: do not import unnecessary things here to keep cli startup time under # control from pathlib import Path -from typing import Dict, List, Tuple +from typing import Dict, Iterable, List, Tuple, cast import luigi @@ -148,7 +148,8 @@ # and escape(name) sha256_to_names: Dict[bytes, Tuple[bytes, str]] = {} with pyzstd.open(self.deanonymization_table_path, "rt") as fd: - csv_reader = csv.reader(fd) + # TODO: remove that cast once we dropped Python 3.7 support + csv_reader = csv.reader(cast(Iterable[str], fd)) header = next(csv_reader) assert header == ["sha256_base64", "base64", "escaped"], header for line in csv_reader: @@ -179,7 +180,8 @@ # Open input for reads as CSV with pyzstd.open(self.origin_contributors_path, "rt") as input_fd: - csv_reader = csv.reader(input_fd) + # TODO: remove that cast once we dropped Python 3.7 support + csv_reader = csv.reader(cast(Iterable[str], input_fd)) header = next(csv_reader) assert header == ["origin_SWHID", "person_id"], header for (origin_swhid, person_id) in csv_reader: