diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe300ff..988a4c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: os: - ubuntu-latest python-version: - - '3.6' - - '3.9' + - '3.7' + - '3.11' steps: - name: 'Set up Python ${{ matrix.python-version }}' uses: actions/setup-python@v2 @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v2 - run: 'pip install -e . -r requirements-test.txt' - run: py.test -vvv --cov . - - run: 'bash <(curl -s https://codecov.io/bash)' + - uses: codecov/codecov-action@v3 env: BOTO_CONFIG: /dev/null AWS_SECRET_ACCESS_KEY: foobar_secret @@ -34,7 +34,7 @@ jobs: steps: - uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: '3.11' - uses: actions/checkout@v2 - run: 'pip install -e . -r requirements-lint.txt' - run: flake8 hai @@ -44,7 +44,7 @@ jobs: steps: - uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: '3.11' - uses: actions/checkout@v2 - run: 'pip install build' - run: python -m build . diff --git a/hai/boto3_multipart_upload.py b/hai/boto3_multipart_upload.py index 80eb0ec..f90ff94 100644 --- a/hai/boto3_multipart_upload.py +++ b/hai/boto3_multipart_upload.py @@ -134,7 +134,7 @@ def upload_file( raise TypeError('`fp` must have a `read()` method') try: - size = os.stat(fp.fileno()).st_size # type: Optional[int] + size = os.stat(fp.fileno()).st_size except (OSError, AttributeError): size = None diff --git a/hai/event_emitter.py b/hai/event_emitter.py index cdd341f..5e2c63a 100644 --- a/hai/event_emitter.py +++ b/hai/event_emitter.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict, Optional +from typing import Any, Callable, Dict, Optional, Set DICT_NAME = '_event_emitter_dict' @@ -10,7 +10,7 @@ def _get_event_emitter_dict(obj: Any) -> Dict[str, Any]: class EventEmitter: - event_types = set() # type: set[str] + event_types: Set[str] = set() def on(self, event: str, handler: Handler) -> None: if event != '*' and event not in self.event_types: diff --git a/hai/parallel.py b/hai/parallel.py index 9ed9d61..613bb59 100644 --- a/hai/parallel.py +++ b/hai/parallel.py @@ -45,8 +45,8 @@ class ParallelRun: def __init__(self, parallelism: Optional[int] = None) -> None: self.pool = ThreadPool(processes=(parallelism or (int(os.cpu_count() or 1) * 2))) self.task_complete_event = threading.Event() - self.tasks = [] # type: List[ApplyResult[Any]] - self.completed_tasks = WeakSet() # type: WeakSet[ApplyResult[Any]] + self.tasks: List[ApplyResult[Any]] = [] + self.completed_tasks: WeakSet[ApplyResult[Any]] = WeakSet() def __enter__(self) -> "ParallelRun": return self diff --git a/hai/pipe_pump.py b/hai/pipe_pump.py index a54b821..8a68799 100644 --- a/hai/pipe_pump.py +++ b/hai/pipe_pump.py @@ -12,7 +12,7 @@ class BasePipePump: def __init__(self) -> None: self.selector = selectors.DefaultSelector() - self.buffers = {} # type: Dict[str, bytes] + self.buffers: Dict[str, bytes] = {} self.selector_lock = threading.Lock() def register(self, key: str, fileobj: Optional[IO[bytes]]) -> None: @@ -46,7 +46,7 @@ def pump(self, timeout: float = 0, max_reads: int = 1) -> int: read_num += 1 should_repeat = False for (key, _event) in self.selector.select(timeout=timeout): - fileobj = key.fileobj # type: IO[bytes] # type: ignore[assignment] + fileobj: IO[bytes] = key.fileobj # type: ignore[assignment] data = fileobj.read(self.read_size) self.feed(key.data, data) should_repeat = True # Got data, should try again @@ -125,8 +125,8 @@ def __init__(self, separator: bytes = b'\n') -> None: super().__init__() assert isinstance(separator, bytes) self.separator = separator - self.lines = {} # type: Dict[str, List[bytes]] - self._line_handlers = [] # type: List[LineHandler] + self.lines: Dict[str, List[bytes]] = {} + self._line_handlers: List[LineHandler] = [] def add_line_handler(self, handler: LineHandler) -> None: """ @@ -241,8 +241,8 @@ class CRLFPipePump(BasePipePump): def __init__(self) -> None: super().__init__() - self.line_state = {} # type: Dict[str, Tuple[Optional[bytes], bool]] - self._handlers = [] # type: List[CRLFHandler] + self.line_state: Dict[str, Tuple[Optional[bytes], bool]] = {} + self._handlers: List[CRLFHandler] = [] def add_handler(self, handler: CRLFHandler) -> None: """ diff --git a/hai/rate_limiter.py b/hai/rate_limiter.py index bcdd183..45e1d3b 100644 --- a/hai/rate_limiter.py +++ b/hai/rate_limiter.py @@ -91,9 +91,9 @@ def __init__(self, rate: Rate, allow_underflow: bool = False) -> None: """ self.rate = rate self.allow_underflow = bool(allow_underflow) - self.last_check = None # type: Optional[float] - self.allowance = None # type: Optional[float] - self.current_state = None # type: Optional[bool] + self.last_check: Optional[float] = None + self.allowance: Optional[float] = None + self.current_state: Optional[bool] = None @classmethod def from_per_second(cls, per_second: int, allow_underflow: bool = False) -> "RateLimiter": @@ -155,7 +155,7 @@ class MultiRateLimiter: allow_underflow = False def __init__(self, default_limit: Rate, per_name_limits: Optional[Dict[str, Rate]] = None) -> None: - self.limiters = {} # type: Dict[str, RateLimiter] + self.limiters: Dict[str, RateLimiter] = {} self.default_limit = default_limit self.per_name_limits = dict(per_name_limits or {}) assert isinstance(default_limit, Rate) diff --git a/requirements-lint.txt b/requirements-lint.txt index 7cd8ac9..3c7a5cc 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -1,35 +1,33 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile requirements-lint.in # -attrs==21.2.0 +attrs==22.1.0 # via flake8-bugbear -flake8==4.0.1 +flake8==6.0.0 # via # -r requirements-lint.in # flake8-bugbear # flake8-isort -flake8-bugbear==21.9.2 +flake8-bugbear==22.12.6 # via -r requirements-lint.in -flake8-isort==4.1.1 +flake8-isort==5.0.3 # via -r requirements-lint.in isort==5.10.1 # via flake8-isort -mccabe==0.6.1 +mccabe==0.7.0 # via flake8 -mypy==0.910 +mypy==0.991 # via -r requirements-lint.in mypy-extensions==0.4.3 # via mypy -pycodestyle==2.8.0 +pycodestyle==2.10.0 # via flake8 -pyflakes==2.4.0 +pyflakes==3.0.1 # via flake8 -testfixtures==6.18.3 - # via flake8-isort -toml==0.10.2 +tomli==2.0.1 # via mypy -typing-extensions==4.0.0 +typing-extensions==4.4.0 # via mypy diff --git a/requirements-test.txt b/requirements-test.txt index 75f12ec..52f41a9 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,86 +1,87 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile requirements-test.in # -attrs==21.2.0 +attrs==22.1.0 # via pytest -boto3==1.20.13 +boto3==1.26.25 # via moto -botocore==1.23.13 +botocore==1.29.25 # via # boto3 # moto # s3transfer -certifi==2021.10.8 +certifi==2022.12.7 # via requests -cffi==1.15.0 +cffi==1.15.1 # via cryptography -charset-normalizer==2.0.8 +charset-normalizer==2.1.1 # via requests -coverage[toml]==6.1.2 +coverage[toml]==6.5.0 # via pytest-cov -cryptography==36.0.0 +cryptography==38.0.4 # via moto -idna==3.3 +exceptiongroup==1.0.4 + # via pytest +idna==3.4 # via requests iniconfig==1.1.1 # via pytest -jinja2==3.0.3 +jinja2==3.1.2 # via moto -jmespath==0.10.0 +jmespath==1.0.1 # via # boto3 # botocore -markupsafe==2.0.1 +markupsafe==2.1.1 # via # jinja2 # moto -moto==2.2.16 + # werkzeug +moto==4.0.11 # via -r requirements-test.in -packaging==21.3 +packaging==22.0 # via pytest pluggy==1.0.0 # via pytest -py==1.11.0 - # via pytest pycparser==2.21 # via cffi -pyparsing==3.0.6 - # via packaging -pytest==6.2.5 +pytest==7.2.0 # via pytest-cov -pytest-cov==3.0.0 +pytest-cov==4.0.0 # via -r requirements-test.in python-dateutil==2.8.2 # via # botocore # moto -pytz==2021.3 +pytz==2022.6 # via moto -requests==2.26.0 +requests==2.28.1 # via # moto # responses -responses==0.16.0 +responses==0.22.0 # via moto -s3transfer==0.5.0 +s3transfer==0.6.0 # via boto3 six==1.16.0 - # via - # python-dateutil - # responses + # via python-dateutil toml==0.10.2 - # via pytest -tomli==1.2.2 - # via coverage -urllib3==1.26.7 + # via responses +tomli==2.0.1 + # via + # coverage + # pytest +types-toml==0.10.8.1 + # via responses +urllib3==1.26.13 # via # botocore # requests # responses -werkzeug==2.0.2 +werkzeug==2.2.2 # via moto -xmltodict==0.12.0 +xmltodict==0.13.0 # via moto diff --git a/setup.cfg b/setup.cfg index b6b9ae7..ad6e1b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ url = https://github.com/valohai/hai [options] packages = find: -python_requires = >=3.6 +python_requires = >=3.7 include_package_data = true [options.packages.find]