Skip to content

Add a static stubs directory #10485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ stubs:
sed -e "s,__version__,`python -msetuptools_scm`," < setup.py-stubs > circuitpython-stubs/setup.py
cp README.rst-stubs circuitpython-stubs/README.rst
cp MANIFEST.in-stubs circuitpython-stubs/MANIFEST.in
cp -r stubs/* circuitpython-stubs
$(PYTHON) tools/board_stubs/build_board_specific_stubs/board_stub_builder.py
cp -r tools/board_stubs/circuitpython_setboard circuitpython-stubs/circuitpython_setboard
$(PYTHON) -m build circuitpython-stubs
Expand Down
2 changes: 1 addition & 1 deletion docs/library/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ the following libraries.
.. toctree::
:maxdepth: 1

micropython.rst
../../shared-bindings/micropython/index.rst
157 changes: 0 additions & 157 deletions docs/library/micropython.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/redirects.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
index.rst README.html
docs/library/micropython.rst shared-bindings/micropython
shared-bindings//__init__.rst shared-bindings//
shared-bindings/_bleio/Adapter.rst shared-bindings/_bleio/#_bleio.Adapter
shared-bindings/_bleio/Address.rst shared-bindings/_bleio/#_bleio.Address
Expand Down
20 changes: 20 additions & 0 deletions stubs/micropython/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Access and control MicroPython internals"""

def const[T](expr: T) -> T:
"""Used to declare that the expression is a constant so that the compiler
can optimise it. The use of this function should be as follows::

from micropython import const

CONST_X = const(123)
CONST_Y = const(2 * CONST_X + 1)

Constants declared this way are still accessible as global variables from
outside the module they are declared in. On the other hand, if a constant
begins with an underscore then it is hidden, it is not available as a global
variable, and does not take up any memory during execution.

This `const` function is recognised directly by the MicroPython parser and is
provided as part of the :mod:`micropython` module mainly so that scripts can be
written which run under both CPython and MicroPython, by following the above
pattern."""