Skip to content

Commit db2ce6d

Browse files
author
Andrei Neagu
committed
mypy
1 parent cdf5a93 commit db2ce6d

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
lines changed

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rest/containers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ async def get_container_logs(
241241
if timestamps:
242242
args["timestamps"] = True
243243

244-
container_logs: list[str] = await container_instance.log(**args)
244+
container_logs: list[str] = await container_instance.log(
245+
**args
246+
) # type:ignore[call-overload]
245247
return container_logs
246248

247249

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from collections.abc import AsyncGenerator, Iterable
33
from contextlib import asynccontextmanager
4-
from typing import Any, cast
4+
from typing import Any
55

66
import aiodocker
77
import yaml
@@ -65,7 +65,7 @@ async def _get_container(
6565
docker: aiodocker.Docker, container_name: str
6666
) -> DockerContainer | None:
6767
try:
68-
return cast(DockerContainer, await docker.containers.get(container_name))
68+
return await docker.containers.get(container_name)
6969
except aiodocker.DockerError as e:
7070
if e.status == http_status.HTTP_404_NOT_FOUND:
7171
return None

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/attribute_monitor/_logging_event_handler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class _LoggingEventHandler(SafeFileSystemEventHandler):
2727
def event_handler(self, event: FileSystemEvent) -> None:
2828
# NOTE: runs in the created process
2929

30-
file_path = Path(event.src_path)
30+
file_path = Path(
31+
event.src_path.decode()
32+
if isinstance(event.src_path, bytes)
33+
else event.src_path
34+
)
3135
with suppress(FileNotFoundError):
3236
file_stat = file_path.stat()
3337
logger.info(

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/attribute_monitor/_watchdog_extensions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515

1616

1717
class _ExtendedInotifyBuffer(InotifyBuffer):
18-
def __init__(self, path, recursive=False): # pylint:disable=super-init-not-called
18+
def __init__(
19+
self, path: bytes, *, recursive: bool = False
20+
): # pylint:disable=super-init-not-called
1921
# below call to `BaseThread.__init__` is correct since we want to
2022
# overwrite the `InotifyBuffer.__init__` method
2123
BaseThread.__init__(self) # pylint:disable=non-parent-init-called
2224
self._queue = DelayedQueue(self.delay)
2325
self._inotify = Inotify( # pylint:disable=too-many-function-args
24-
path, recursive, InotifyConstants.IN_ATTRIB
26+
path, recursive=recursive, event_mask=InotifyConstants.IN_ATTRIB
2527
)
2628
self.start()
2729

@@ -30,7 +32,7 @@ class _ExtendedInotifyEmitter(InotifyEmitter):
3032
def on_thread_start(self):
3133
path = os.fsencode(self.watch.path)
3234
# pylint:disable=attribute-defined-outside-init
33-
self._inotify = _ExtendedInotifyBuffer(path, self.watch.is_recursive)
35+
self._inotify = _ExtendedInotifyBuffer(path, recursive=self.watch.is_recursive)
3436

3537

3638
class ExtendedInotifyObserver(BaseObserver):

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/outputs/_event_handler.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ def event_handler(self, event: FileSystemEvent) -> None:
4949
# NOTE: ignoring all events which are not relative to modifying
5050
# the contents of the `port_key` folders from the outputs directory
5151

52-
path_relative_to_outputs = Path(event.src_path).relative_to(self.outputs_path)
52+
path_relative_to_outputs = Path(
53+
event.src_path.decode()
54+
if isinstance(event.src_path, bytes)
55+
else event.src_path
56+
).relative_to(self.outputs_path)
5357

5458
# discard event if not part of a subfolder
5559
relative_path_parents = path_relative_to_outputs.parents

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/outputs/_watchdog_extensions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131

3232

3333
class _ExtendedInotifyBuffer(InotifyBuffer):
34-
def __init__(self, path, recursive=False): # pylint:disable=super-init-not-called
34+
def __init__(
35+
self, path: bytes, *, recursive: bool = False
36+
): # pylint:disable=super-init-not-called
3537
# below call to `BaseThread.__init__` is correct since we want to
3638
# overwrite the `InotifyBuffer.__init__` method
3739
BaseThread.__init__(self) # pylint:disable=non-parent-init-called
3840
self._queue = DelayedQueue(self.delay)
3941
self._inotify = Inotify( # pylint:disable=too-many-function-args
40-
path, recursive, _EVENTS_TO_WATCH
42+
path, recursive=recursive, event_mask=_EVENTS_TO_WATCH
4143
)
4244
self.start()
4345

@@ -46,7 +48,7 @@ class _ExtendedInotifyEmitter(InotifyEmitter):
4648
def on_thread_start(self):
4749
path = os.fsencode(self.watch.path)
4850
# pylint:disable=attribute-defined-outside-init
49-
self._inotify = _ExtendedInotifyBuffer(path, self.watch.is_recursive)
51+
self._inotify = _ExtendedInotifyBuffer(path, recursive=self.watch.is_recursive)
5052

5153

5254
class ExtendedInotifyObserver(BaseObserver):

0 commit comments

Comments
 (0)