scirodev 0.5.2__tar.gz → 0.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scirodev
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev
5
5
  Author: Thomas Schank
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scirodev"
7
- version = "0.5.2"
7
+ version = "0.5.3"
8
8
  description = "PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -4,7 +4,56 @@ helpers. EXPERIMENTAL: the API may still change between releases.
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
- from typing import Awaitable, Callable, Iterable, Iterator, Optional, Sequence, Tuple
7
+ from typing import (
8
+ TYPE_CHECKING,
9
+ Any,
10
+ Awaitable,
11
+ Callable,
12
+ Iterable,
13
+ Iterator,
14
+ Optional,
15
+ Sequence,
16
+ Tuple,
17
+ )
18
+
19
+ if TYPE_CHECKING:
20
+ from pybricks._common import MaybeAwaitableTuple
21
+ else:
22
+ # Upstream defines this only for type checkers; runtime importers of the
23
+ # stubs (the docs build) need a value. Annotations are strings here
24
+ # (from __future__ import annotations), so a placeholder suffices.
25
+ MaybeAwaitableTuple = None
26
+
27
+
28
+ def multitask(*coroutines: Awaitable[Any], race: bool = False) -> MaybeAwaitableTuple:
29
+ """multitask(coroutine1, coroutine2, ..., race=False) -> Tuple
30
+
31
+ ``pybricks.tools.multitask`` (the same function on the hub), typed to
32
+ accept any awaitable.
33
+
34
+ The upstream stub asks for ``Coroutine``, which every *maybe-awaitable*
35
+ hub method fails to satisfy for a type checker: ``motor.run_angle(...)``,
36
+ ``db.straight(...)`` or ``sensor.read()`` are declared as awaitables, not
37
+ as coroutines, because they return a plain value when called outside
38
+ ``run_task``. Importing ``multitask`` (and :func:`run_task`) from
39
+ ``sciro.tools`` instead of ``pybricks.tools`` removes those warnings::
40
+
41
+ from sciro.tools import multitask, run_task
42
+
43
+ async def main():
44
+ await multitask(db.straight(500), log.record(db.state), race=True)
45
+
46
+ run_task(main())
47
+ """
48
+
49
+
50
+ def run_task(coroutine: Optional[Awaitable[Any]] = None) -> Optional[bool]:
51
+ """run_task(coroutine) -> bool | None
52
+
53
+ ``pybricks.tools.run_task`` (the same function on the hub), typed to
54
+ accept any awaitable; see :func:`multitask`. Without an argument it
55
+ returns whether the run loop is active.
56
+ """
8
57
 
9
58
 
10
59
  class RingBuffer:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scirodev
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: PeakHub / sciro extensions to Pybricks: typed API stubs (sciro.*) and hub tooling on top of pybricksdev
5
5
  Author: Thomas Schank
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes