Skip to content

Commit 18be46c

Browse files
committed
Add v1.22.0 STM32 stubs
Signed-off-by: Jos Verlinde <[email protected]>
1 parent 8be98eb commit 18be46c

File tree

392 files changed

+52425
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

392 files changed

+52425
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Jos Verlinde
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# micropython-stm32-pybv11-stubs
2+
3+
4+
This is a stub-only package for MicroPython.
5+
It is intended to be installed in a projects virtual environment to allow static type checkers and intellisense features to be used while writing Micropython code.
6+
7+
The version of this package is alligned the the version of the MicroPython firmware.
8+
- Major, Minor and Patch levels are alligned to the same version as the firmware.
9+
- The post release level is used to publish new releases of the stubs.
10+
11+
For `Micropython 1.17` the stubs are published as `1.17.post1` ... `1.17.post2`
12+
for `Micropython 1.18` the stubs are published as `1.18.post1` ... `1.18.post2`
13+
14+
To install the latest stubs:
15+
`pip install -I micropython-<port>-stubs` where port is the port of the MicroPython firmware.
16+
17+
To install the stubs for an older version, such as MicroPython 1.17:
18+
`pip install micropython-stm32-stubs==1.17.*` which will install the last post release of the stubs for MicroPython 1.17.
19+
20+
21+
As the creation of the stubs, and merging of the different types is still going though improvements, the stub packages are marked as Beta.
22+
To upgrade stubs to the latest stubs for a specific version use `pip install micropython-stm32-stubs==1.17.* --upgrade`
23+
24+
If you have suggestions or find any issues with the stubs, please report them in the [MicroPython-stubs Discussions](https://github.com/Josverl/micropython-stubs/discussions)
25+
26+
For an overview of Micropython Stubs please see: https://micropython-stubs.readthedocs.io/en/main/
27+
* List of all stubs : https://micropython-stubs.readthedocs.io/en/main/firmware_grp.html
28+
29+
Included stubs:
30+
* Merged stubs from `stubs/micropython-v1_22_0-stm32-PYBV11-merged`
31+
* Core stubs from `stubs/micropython-core`
32+
33+
34+
origin | Family | Port | Board | Version
35+
-------|--------|------|-------|--------
36+
Documentation | micropython | - | - | v1.22.0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Allows for type checking of Micropython specific builtins by pyright and pylance.
2+
"""
3+
4+
from typing import Tuple, TypeVar
5+
6+
Const_T = TypeVar("Const_T", int, float, str, bytes, Tuple) # constant
7+
8+
def const(expr: Const_T) -> Const_T:
9+
"""
10+
Used to declare that the expression is a constant so that the compiler can
11+
optimise it. The use of this function should be as follows::
12+
13+
from micropython import const
14+
15+
CONST_X = const(123)
16+
CONST_Y = const(2 * CONST_X + 1)
17+
18+
Constants declared this way are still accessible as global variables from
19+
outside the module they are declared in. On the other hand, if a constant
20+
begins with an underscore then it is hidden, it is not available as a global
21+
variable, and does not take up any memory during execution.
22+
23+
This `const` function is recognised directly by the MicroPython parser and is
24+
provided as part of the :mod:`micropython` module mainly so that scripts can be
25+
written which run under both CPython and MicroPython, by following the above
26+
pattern.
27+
"""
28+
...
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Asynchronous I/O scheduler for writing concurrent code.
3+
4+
MicroPython module: https://docs.micropython.org/en/v1.22.0/library/asyncio.html
5+
6+
CPython module:
7+
`asyncio `<https://docs.python.org/3.8/library/asyncio.html>
8+
9+
Example::
10+
11+
import asyncio
12+
13+
async def blink(led, period_ms):
14+
while True:
15+
led.on()
16+
await asyncio.sleep_ms(5)
17+
led.off()
18+
await asyncio.sleep_ms(period_ms)
19+
20+
async def main(led1, led2):
21+
asyncio.create_task(blink(led1, 700))
22+
asyncio.create_task(blink(led2, 400))
23+
await asyncio.sleep_ms(10_000)
24+
25+
# Running on a pyboard
26+
from pyb import LED
27+
asyncio.run(main(LED(1), LED(2)))
28+
29+
# Running on a generic board
30+
from machine import Pin
31+
asyncio.run(main(Pin(1), Pin(2)))
32+
33+
Core functions
34+
--------------
35+
"""
36+
from _typeshed import Incomplete, Incomplete as Incomplete
37+
from typing import Any, Coroutine, List, Tuple
38+
39+
class TaskQueue:
40+
def push(self, *args, **kwargs) -> Incomplete: ...
41+
def peek(self, *args, **kwargs) -> Incomplete: ...
42+
def remove(self, *args, **kwargs) -> Incomplete: ...
43+
def pop(self, *args, **kwargs) -> Incomplete: ...
44+
def __init__(self, *argv, **kwargs) -> None: ...
45+
46+
class Task:
47+
"""
48+
This object wraps a coroutine into a running task. Tasks can be waited on
49+
using ``await task``, which will wait for the task to complete and return
50+
the return value of the task.
51+
52+
Tasks should not be created directly, rather use `create_task` to create them.
53+
"""
54+
55+
def __init__(self, *argv, **kwargs) -> None: ...
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from _typeshed import Incomplete as Incomplete
2+
3+
def reset(*args, **kwargs) -> Incomplete: ...
4+
def writebyte(*args, **kwargs) -> Incomplete: ...
5+
def writebit(*args, **kwargs) -> Incomplete: ...
6+
def crc8(*args, **kwargs) -> Incomplete: ...
7+
def readbyte(*args, **kwargs) -> Incomplete: ...
8+
def readbit(*args, **kwargs) -> Incomplete: ...
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Efficient arrays of numeric data.
3+
4+
MicroPython module: https://docs.micropython.org/en/v1.22.0/library/array.html
5+
6+
CPython module: :mod:`python:array` https://docs.python.org/3/library/array.html .
7+
8+
Supported format codes: ``b``, ``B``, ``h``, ``H``, ``i``, ``I``, ``l``,
9+
``L``, ``q``, ``Q``, ``f``, ``d`` (the latter 2 depending on the
10+
floating-point support).
11+
"""
12+
from _typeshed import Incomplete, Incomplete as Incomplete
13+
from typing import Any, List, Optional
14+
15+
class array(List):
16+
"""
17+
Create array with elements of given type. Initial contents of the
18+
array are given by *iterable*. If it is not provided, an empty
19+
array is created.
20+
"""
21+
22+
def extend(self, iterable) -> Incomplete:
23+
"""
24+
Append new elements as contained in *iterable* to the end of
25+
array, growing it.
26+
"""
27+
...
28+
def append(self, val) -> Incomplete:
29+
"""
30+
Append new element *val* to the end of array, growing it.
31+
"""
32+
...
33+
def __init__(self, *argv, **kwargs) -> None: ...
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
"""
2+
Asynchronous I/O scheduler for writing concurrent code.
3+
4+
MicroPython module: https://docs.micropython.org/en/v1.22.0/library/asyncio.html
5+
6+
CPython module:
7+
`asyncio `<https://docs.python.org/3.8/library/asyncio.html>
8+
9+
Example::
10+
11+
import asyncio
12+
13+
async def blink(led, period_ms):
14+
while True:
15+
led.on()
16+
await asyncio.sleep_ms(5)
17+
led.off()
18+
await asyncio.sleep_ms(period_ms)
19+
20+
async def main(led1, led2):
21+
asyncio.create_task(blink(led1, 700))
22+
asyncio.create_task(blink(led2, 400))
23+
await asyncio.sleep_ms(10_000)
24+
25+
# Running on a pyboard
26+
from pyb import LED
27+
asyncio.run(main(LED(1), LED(2)))
28+
29+
# Running on a generic board
30+
from machine import Pin
31+
asyncio.run(main(Pin(1), Pin(2)))
32+
33+
Core functions
34+
--------------
35+
"""
36+
from _typeshed import Incomplete, Incomplete as Incomplete
37+
from typing import Any, Coroutine, List, Tuple
38+
39+
def ticks_diff(*args, **kwargs) -> Incomplete: ...
40+
def get_event_loop() -> Incomplete:
41+
"""
42+
Return the event loop used to schedule and run tasks. See `Loop`.
43+
"""
44+
...
45+
46+
def current_task() -> Task:
47+
"""
48+
Return the `Task` object associated with the currently running task.
49+
"""
50+
...
51+
52+
def create_task(coro) -> Task:
53+
"""
54+
Create a new task from the given coroutine and schedule it to run.
55+
56+
Returns the corresponding `Task` object.
57+
"""
58+
...
59+
60+
def new_event_loop() -> Incomplete:
61+
"""
62+
Reset the event loop and return it.
63+
64+
Note: since MicroPython only has a single event loop this function just
65+
resets the loop's state, it does not create a new one.
66+
"""
67+
...
68+
69+
def ticks(*args, **kwargs) -> Incomplete: ...
70+
def run_until_complete(*args, **kwargs) -> Incomplete: ...
71+
def run(coro) -> Incomplete:
72+
"""
73+
Create a new task from the given coroutine and run it until it completes.
74+
75+
Returns the value returned by *coro*.
76+
"""
77+
...
78+
79+
def wait_for_ms(awaitable, timeout) -> Coroutine[Incomplete, Any, Any]:
80+
"""
81+
Similar to `wait_for` but *timeout* is an integer in milliseconds.
82+
83+
This is a coroutine, and a MicroPython extension.
84+
"""
85+
...
86+
87+
def sleep_ms(t) -> Coroutine[Incomplete, Any, Any]:
88+
"""
89+
Sleep for *t* milliseconds.
90+
91+
This is a coroutine, and a MicroPython extension.
92+
"""
93+
...
94+
95+
def ticks_add(*args, **kwargs) -> Incomplete: ...
96+
def sleep(t) -> Coroutine[Incomplete, Any, Any]:
97+
"""
98+
Sleep for *t* seconds (can be a float).
99+
100+
This is a coroutine.
101+
"""
102+
...
103+
104+
class TaskQueue:
105+
def push(self, *args, **kwargs) -> Incomplete: ...
106+
def peek(self, *args, **kwargs) -> Incomplete: ...
107+
def remove(self, *args, **kwargs) -> Incomplete: ...
108+
def pop(self, *args, **kwargs) -> Incomplete: ...
109+
def __init__(self, *argv, **kwargs) -> None: ...
110+
111+
open_connection: Incomplete
112+
113+
class Event:
114+
"""
115+
Create a new event which can be used to synchronise tasks. Events start
116+
in the cleared state.
117+
"""
118+
119+
def set(self) -> None:
120+
"""
121+
Set the event. Any tasks waiting on the event will be scheduled to run.
122+
123+
Note: This must be called from within a task. It is not safe to call this
124+
from an IRQ, scheduler callback, or other thread. See `ThreadSafeFlag`.
125+
"""
126+
...
127+
def is_set(self) -> bool:
128+
"""
129+
Returns ``True`` if the event is set, ``False`` otherwise.
130+
"""
131+
...
132+
def clear(self) -> None:
133+
"""
134+
Clear the event.
135+
"""
136+
...
137+
wait: Incomplete
138+
def __init__(self, *argv, **kwargs) -> None: ...
139+
140+
class Lock:
141+
"""
142+
Create a new lock which can be used to coordinate tasks. Locks start in
143+
the unlocked state.
144+
145+
In addition to the methods below, locks can be used in an ``async with`` statement.
146+
"""
147+
148+
def locked(self) -> bool:
149+
"""
150+
Returns ``True`` if the lock is locked, otherwise ``False``.
151+
"""
152+
...
153+
def release(self) -> Incomplete:
154+
"""
155+
Release the lock. If any tasks are waiting on the lock then the next one in the
156+
queue is scheduled to run and the lock remains locked. Otherwise, no tasks are
157+
waiting an the lock becomes unlocked.
158+
"""
159+
...
160+
acquire: Incomplete
161+
def __init__(self, *argv, **kwargs) -> None: ...
162+
163+
class Task:
164+
"""
165+
This object wraps a coroutine into a running task. Tasks can be waited on
166+
using ``await task``, which will wait for the task to complete and return
167+
the return value of the task.
168+
169+
Tasks should not be created directly, rather use `create_task` to create them.
170+
"""
171+
172+
def __init__(self, *argv, **kwargs) -> None: ...
173+
174+
wait_for: Incomplete
175+
176+
class CancelledError(Exception): ...
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from _typeshed import Incomplete as Incomplete
2+
3+
def ticks(*args, **kwargs) -> Incomplete: ...
4+
def current_task(*args, **kwargs) -> Incomplete: ...
5+
def create_task(*args, **kwargs) -> Incomplete: ...
6+
def ticks_diff(*args, **kwargs) -> Incomplete: ...
7+
def get_event_loop(*args, **kwargs) -> Incomplete: ...
8+
def run_until_complete(*args, **kwargs) -> Incomplete: ...
9+
def run(*args, **kwargs) -> Incomplete: ...
10+
def new_event_loop(*args, **kwargs) -> Incomplete: ...
11+
def sleep_ms(*args, **kwargs) -> Incomplete: ...
12+
def ticks_add(*args, **kwargs) -> Incomplete: ...
13+
def sleep(*args, **kwargs) -> Incomplete: ...
14+
15+
class TaskQueue:
16+
def push(self, *args, **kwargs) -> Incomplete: ...
17+
def peek(self, *args, **kwargs) -> Incomplete: ...
18+
def remove(self, *args, **kwargs) -> Incomplete: ...
19+
def pop(self, *args, **kwargs) -> Incomplete: ...
20+
def __init__(self, *argv, **kwargs) -> None: ...
21+
22+
class Task:
23+
def __init__(self, *argv, **kwargs) -> None: ...
24+
25+
class CancelledError(Exception): ...

0 commit comments

Comments
 (0)