Skip to content

Commit 0350d37

Browse files
committed
Add missing type hints
Thanks, mypy/stubgen, for pointing out the Incomplete ones.
1 parent e5b067a commit 0350d37

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/appose/environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343
class Environment:
4444
def __init__(self, base: Path | str, use_system_path: bool = False):
45-
self.base = Path(base).absolute()
46-
self.use_system_path = use_system_path
45+
self.base: Path = Path(base).absolute()
46+
self.use_system_path: bool = use_system_path
4747

4848
def python(self) -> Service:
4949
"""

src/appose/python_worker.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ def __init__(
6262
inputs: Args | None = None,
6363
) -> None:
6464
self._worker: Worker = worker or Worker()
65-
self._uuid = uuid
66-
self._script = script
67-
self._inputs = inputs
65+
self._uuid: str | None = uuid
66+
self._script: str | None = script
67+
self._inputs: Args | None = inputs
6868
self._finished = False
69-
self._thread = None
69+
self._thread: Thread | None = None
7070

7171
# Public-facing fields for use within the task script.
72-
self.outputs = {}
72+
self.outputs: Args = {}
7373
self.cancel_requested = False
7474

7575
def export(self, **kwargs):
@@ -80,7 +80,7 @@ def update(
8080
message: str | None = None,
8181
current: int | None = None,
8282
maximum: int | None = None,
83-
info: dict[str, Any] | None = None,
83+
info: Args | None = None,
8484
) -> None:
8585
args = {}
8686
if message is not None:
@@ -195,9 +195,9 @@ def _respond(self, response_type: ResponseType, args: Args | None) -> None:
195195

196196
class Worker:
197197
def __init__(self):
198-
self.tasks = {}
198+
self.tasks: dict[str, Task] = {}
199199
self.queue: list[Task] = []
200-
self.exports = {}
200+
self.exports[str, Any] = {}
201201

202202
# Flag this process as a worker, not a service.
203203
_set_worker(True)

src/appose/service.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ class Service:
5252
service of updates via communication over pipes (stdin and stdout).
5353
"""
5454

55-
_service_count = 0
55+
_service_count: int = 0
5656

5757
def __init__(self, cwd: str | Path, args: list[str]) -> None:
58-
self._cwd = cwd
59-
self._args = args[:]
58+
self._cwd: str | Path = cwd
59+
self._args: list[str] = args[:]
6060
self._tasks: dict[str, "Task"] = {}
61-
self._service_id = Service._service_count
61+
self._service_id: int = Service._service_count
6262
Service._service_count += 1
6363
self._process: subprocess.Popen | None = None
6464
self._stdout_thread: threading.Thread | None = None
@@ -283,14 +283,14 @@ def __init__(
283283
message: str | None = None,
284284
current: int | None = None,
285285
maximum: int | None = None,
286-
info: dict[str, Any] | None = None,
286+
info: Args | None = None,
287287
) -> None:
288288
self.task: "Task" = task
289289
self.response_type: ResponseType = response_type
290290
self.message: str | None = message
291291
self.current: int | None = current
292292
self.maximum: int | None = maximum
293-
self.info: dict[str, Any] | None = info
293+
self.info: Args | None = info
294294

295295
def __str__(self):
296296
return f"[{self.response_type}] {self.task}"
@@ -311,8 +311,8 @@ def __init__(
311311
queue: str | None = None,
312312
) -> None:
313313
self.uuid: str = uuid4().hex
314-
self.service = service
315-
self.script = script
314+
self.service: Service = service
315+
self.script: str = script
316316
self.inputs: Args = {}
317317
self.queue: str | None = queue
318318
if inputs is not None:
@@ -324,7 +324,7 @@ def __init__(
324324
self.maximum: int = 1
325325
self.error: str | None = None
326326
self.listeners: list[Callable[["TaskEvent"], None]] = []
327-
self.cv = threading.Condition()
327+
self.cv: threading.Condition = threading.Condition()
328328
self.service._tasks[self.uuid] = self
329329

330330
def start(self) -> "Task":

src/appose/types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def __init__(self, name: str = None, create: bool = False, rsize: int = 0):
6868
depending on the running platform.
6969
"""
7070
super().__init__(name=name, create=create, size=rsize)
71-
self.rsize = rsize
72-
self._unlink_on_dispose = create
71+
self.rsize: int = rsize
72+
self._unlink_on_dispose: bool = create
7373
if _is_worker:
7474
# HACK: Remove this shared memory block from the resource_tracker,
7575
# which would otherwise want to clean up shared memory blocks
@@ -164,9 +164,9 @@ def __init__(self, dtype: str, shape: list[int], shm: SharedMemory = None):
164164
with resolution 512x512 would have shape [7, 512, 512].
165165
:param shm: The SharedMemory containing the array data, or None to create it.
166166
"""
167-
self.dtype = dtype
168-
self.shape = shape
169-
self.shm = (
167+
self.dtype: str = dtype
168+
self.shape: list[int] = shape
169+
self.shm: SharedMemory = (
170170
SharedMemory(
171171
create=True, rsize=ceil(prod(shape) * _bytes_per_element(dtype))
172172
)

0 commit comments

Comments
 (0)