diff --git a/requirements-dev.txt b/requirements-dev.txt index 573f275..9dc315b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,3 +6,4 @@ pytest-mock pytest-cov mypy types-protobuf +setuptools diff --git a/setup.py b/setup.py index 4a08559..eba0add 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -from __future__ import annotations # for compatibility with Python < 3.11 import pathlib from setuptools import setup diff --git a/utils.py b/utils.py index 84b39f0..89953c8 100644 --- a/utils.py +++ b/utils.py @@ -22,7 +22,7 @@ import re import shutil import sys import pathlib -from typing import BinaryIO, Any, Union +from typing import BinaryIO, Any, Union, List # Types @@ -31,7 +31,8 @@ PathLike = Union[str, pathlib.Path] # Ref. https://stackoverflow.com/a/16571630 -class Capturing(list[Any]): +# PYTHON 3.11: class Capturing(list[Any]): +class Capturing(List[Any]): '''Capture stdout and stderr Usage: with Capturing() as output: @@ -72,19 +73,19 @@ def remove_dir_with_files(dir: PathLike) -> None: if os.path.exists(dir): shutil.rmtree(dir) -def read_csv(filename: str) -> list[list[str]]: +def read_csv(filename: str) -> List[List[str]]: """Returns a list of lines.""" with open(filename, "r", encoding="utf-8", newline='') as infile: - lines: list[list[str]] = [] + lines: List[List[str]] = [] reader = csv.reader(infile) for line in reader: lines.append(line) return lines -def read_csv_str(data_str: str) -> list[list[str]]: +def read_csv_str(data_str: str) -> List[List[str]]: """Returns a list of lines.""" - lines: list[list[str]] = [] + lines: List[List[str]] = [] reader = csv.reader(data_str.splitlines()) for line in reader: lines.append(line) @@ -102,7 +103,7 @@ def read_json_str(data_str: str) -> Any: return json.loads(data_str) -def read_file_to_list(filename: str) -> list[str]: +def read_file_to_list(filename: str) -> List[str]: """Returns a list of lines.""" with open(filename, "r", encoding="utf-8") as infile: return infile.readlines()