diff --git a/.gitignore b/.gitignore index 6dc7fd5..f4bce38 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ coverage-reports/ tools/ venv **/*.mpy +typeshed/ # libs src/*/lib/* diff --git a/Makefile b/Makefile index 84fecc1..b5a0263 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ -PYSQUARED_VERSION ?= v2.0.0-alpha-25w29 +PYSQUARED_VERSION ?= v2.0.0-alpha-25w34 PYSQUARED ?= git+https://github.com/proveskit/pysquared@$(PYSQUARED_VERSION) BOARD_MOUNT_POINT ?= "" BOARD_TTY_PORT ?= "" VERSION ?= $(shell git tag --points-at HEAD --sort=-creatordate < /dev/null | head -n 1) .PHONY: all -all: .venv download-libraries pre-commit-install help +all: .venv typeshed download-libraries pre-commit-install help .PHONY: help help: ## Display this help. @@ -19,6 +19,11 @@ help: ## Display this help. @$(UV) venv @$(UV) sync +typeshed: ## Install CircuitPython typeshed stubs + @echo "Installing CircuitPython typeshed stubs..." + @$(MAKE) uv + @$(UV) pip install circuitpython-typeshed==0.1.0 --target typeshed + .PHONY: download-libraries download-libraries: download-libraries-flight-software download-libraries-ground-station @@ -44,7 +49,8 @@ sync-time: uv ## Syncs the time from your computer to the PROVES Kit board fmt: pre-commit-install ## Lint and format files $(UVX) pre-commit run --all-files -typecheck: .venv download-libraries ## Run type check +.PHONY: typecheck +typecheck: .venv download-libraries typeshed ## Run type check @$(UV) run -m pyright . .PHONY: install diff --git a/pyproject.toml b/pyproject.toml index 6b7d79a..82f9b47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ dev = [ "adafruit-circuitpython-typing==1.12.1", "circuitpython-stubs==9.2.8", "pre-commit==4.2.0", - "pyright[nodejs]==1.1.402", + "pyright[nodejs]==1.1.404", ] [tool.ruff.format] @@ -37,6 +37,8 @@ exclude = [ "artifacts", "src/*/lib", "typings", + "typeshed", ] stubPath = "./typings" +typeshedPath = "./typeshed" reportMissingModuleSource = false diff --git a/typings/gc.pyi b/typings/gc.pyi deleted file mode 100644 index 56dfe3b..0000000 --- a/typings/gc.pyi +++ /dev/null @@ -1,116 +0,0 @@ -""" -Control the garbage collector. - -MicroPython module: https://docs.micropython.org/en/v1.25.0/library/gc.html - -CPython module: :mod:`python:gc` https://docs.python.org/3/library/gc.html . - ---- -Module: 'gc' on micropython-v1.25.0-rp2-RPI_PICO ---- -proveskit: Borrowed from https://github.com/Josverl/micropython-stubs -https://pypi.org/project/micropython-rp2-stubs/#files -""" - -# MCU: {'build': '', 'ver': '1.25.0', 'version': '1.25.0', 'port': 'rp2', 'board': 'RPI_PICO', 'mpy': 'v6.3', 'family': 'micropython', 'cpu': 'RP2040', 'arch': 'armv6m'} -# Stubber: v1.24.0 -from __future__ import annotations - -from typing import overload - -from _typeshed import Incomplete - -def mem_alloc() -> int: - """ - Return the number of bytes of heap RAM that are allocated by Python code. - - Admonition:Difference to CPython - :class: attention - - This function is MicroPython extension. - """ - ... - -def isenabled(*args, **kwargs) -> Incomplete: ... -def mem_free() -> int: - """ - Return the number of bytes of heap RAM that is available for Python - code to allocate, or -1 if this amount is not known. - - Admonition:Difference to CPython - :class: attention - - This function is MicroPython extension. - """ - ... - -@overload -def threshold() -> int: - """ - Set or query the additional GC allocation threshold. Normally, a collection - is triggered only when a new allocation cannot be satisfied, i.e. on an - out-of-memory (OOM) condition. If this function is called, in addition to - OOM, a collection will be triggered each time after *amount* bytes have been - allocated (in total, since the previous time such an amount of bytes - have been allocated). *amount* is usually specified as less than the - full heap size, with the intention to trigger a collection earlier than when the - heap becomes exhausted, and in the hope that an early collection will prevent - excessive memory fragmentation. This is a heuristic measure, the effect - of which will vary from application to application, as well as - the optimal value of the *amount* parameter. - - Calling the function without argument will return the current value of - the threshold. A value of -1 means a disabled allocation threshold. - - Admonition:Difference to CPython - :class: attention - - This function is a MicroPython extension. CPython has a similar - function - ``set_threshold()``, but due to different GC - implementations, its signature and semantics are different. - """ - -@overload -def threshold(amount: int) -> None: - """ - Set or query the additional GC allocation threshold. Normally, a collection - is triggered only when a new allocation cannot be satisfied, i.e. on an - out-of-memory (OOM) condition. If this function is called, in addition to - OOM, a collection will be triggered each time after *amount* bytes have been - allocated (in total, since the previous time such an amount of bytes - have been allocated). *amount* is usually specified as less than the - full heap size, with the intention to trigger a collection earlier than when the - heap becomes exhausted, and in the hope that an early collection will prevent - excessive memory fragmentation. This is a heuristic measure, the effect - of which will vary from application to application, as well as - the optimal value of the *amount* parameter. - - Calling the function without argument will return the current value of - the threshold. A value of -1 means a disabled allocation threshold. - - Admonition:Difference to CPython - :class: attention - - This function is a MicroPython extension. CPython has a similar - function - ``set_threshold()``, but due to different GC - implementations, its signature and semantics are different. - """ - -def collect() -> None: - """ - Run a garbage collection. - """ - ... - -def enable() -> None: - """ - Enable automatic garbage collection. - """ - ... - -def disable() -> None: - """ - Disable automatic garbage collection. Heap memory can still be allocated, - and garbage collection can still be initiated manually using :meth:`gc.collect`. - """ - ... diff --git a/uv.lock b/uv.lock index c255b72..eb562cc 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.13" [[package]] @@ -217,7 +217,7 @@ dev = [ { name = "adafruit-circuitpython-typing", specifier = "==1.12.1" }, { name = "circuitpython-stubs", specifier = "==9.2.8" }, { name = "pre-commit", specifier = "==4.2.0" }, - { name = "pyright", extras = ["nodejs"], specifier = "==1.1.402" }, + { name = "pyright", extras = ["nodejs"], specifier = "==1.1.404" }, ] [[package]] @@ -234,15 +234,15 @@ wheels = [ [[package]] name = "pyright" -version = "1.1.402" +version = "1.1.404" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nodeenv" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/aa/04/ce0c132d00e20f2d2fb3b3e7c125264ca8b909e693841210534b1ea1752f/pyright-1.1.402.tar.gz", hash = "sha256:85a33c2d40cd4439c66aa946fd4ce71ab2f3f5b8c22ce36a623f59ac22937683", size = 3888207, upload-time = "2025-06-11T08:48:35.759Z" } +sdist = { url = "https://files.pythonhosted.org/packages/e2/6e/026be64c43af681d5632722acd100b06d3d39f383ec382ff50a71a6d5bce/pyright-1.1.404.tar.gz", hash = "sha256:455e881a558ca6be9ecca0b30ce08aa78343ecc031d37a198ffa9a7a1abeb63e", size = 4065679, upload-time = "2025-08-20T18:46:14.029Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fe/37/1a1c62d955e82adae588be8e374c7f77b165b6cb4203f7d581269959abbc/pyright-1.1.402-py3-none-any.whl", hash = "sha256:2c721f11869baac1884e846232800fe021c33f1b4acb3929cff321f7ea4e2982", size = 5624004, upload-time = "2025-06-11T08:48:33.998Z" }, + { url = "https://files.pythonhosted.org/packages/84/30/89aa7f7d7a875bbb9a577d4b1dc5a3e404e3d2ae2657354808e905e358e0/pyright-1.1.404-py3-none-any.whl", hash = "sha256:c7b7ff1fdb7219c643079e4c3e7d4125f0dafcc19d253b47e898d130ea426419", size = 5902951, upload-time = "2025-08-20T18:46:12.096Z" }, ] [package.optional-dependencies]