Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 3.6 support #22

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion hai/boto3_multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions hai/event_emitter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, Optional
from typing import Any, Callable, Dict, Optional, Set

DICT_NAME = '_event_emitter_dict'

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions hai/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions hai/pipe_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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:
"""
Expand Down
8 changes: 4 additions & 4 deletions hai/rate_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 12 additions & 14 deletions requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -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
71 changes: 36 additions & 35 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down