Skip to content

Commit

Permalink
make type hints compatible with python 3.8 (#21)
Browse files Browse the repository at this point in the history
* make type hints compatible with python 3.8

* add python 3.8 to pytest matrix

* fail-fast: false
  • Loading branch information
NiklasNeugebauer authored Jun 28, 2024
1 parent 5c3e05e commit 3f219c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ jobs:
pytest:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [3.8, 3.11]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
python-version: ${{ matrix.python-version }}
- name: set up Poetry
uses: abatilo/[email protected]
with:
Expand Down
6 changes: 3 additions & 3 deletions learning_loop_node/detector/outbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from multiprocessing import Event
from multiprocessing.synchronize import Event as SyncEvent
from threading import Thread
from typing import List, Optional
from typing import List, Optional, Tuple, Union

import requests
from fastapi.encoders import jsonable_encoder
Expand Down Expand Up @@ -108,7 +108,7 @@ def upload(self):
self.log.info('No images found to upload')

def _upload_batch(self, items: List[str]):
data: List[tuple[str, TextIOWrapper | BufferedReader]] = []
data: List[Tuple[str, Union[TextIOWrapper, BufferedReader]]] = []
data = [('files', open(f'{item}/image.json', 'r')) for item in items]
data += [('files', open(f'{item}/image.jpg', 'rb')) for item in items]

Expand Down Expand Up @@ -166,7 +166,7 @@ def get_mode(self) -> OutboxMode:
self.log.debug('Outbox: Current mode is %s', current_mode)
return current_mode

def set_mode(self, mode: OutboxMode | str):
def set_mode(self, mode: Union[OutboxMode, str]) -> None:
''':param mode: 'continuous_upload' or 'stopped'
:raises ValueError: if mode is not a valid OutboxMode
:raises TimeoutError: if the upload thread does not terminate within 31 seconds with mode='stopped'
Expand Down

0 comments on commit 3f219c3

Please sign in to comment.