Skip to content

Commit 2c35ac2

Browse files
committed
pyproject.toml: Make ruff aware of MicroPython builtins.
This commit updates the project-wide configuration for `ruff`, in order to not let it flag usages of MicroPython-specific types and keywords when performing code checks. The tool currently has an exceptions list that covers almost all Python code that ships with MicroPython, however code placed in `ports/<port>/modules` (or elsewhere) by users for customisation purposes will end up raising errors for otherwise valid MicroPython-flavoured code. Changes only let `ruff` assume that it knows about the existence of the `micropython` module (used without an initial import) for decorators (eg. `native`, `viper`, `asm_...`, etc.), Viper pointer types (`ptr`, `ptr8`, `ptr16`, `ptr32`), and the `const` constructor. For code that is placed elsewhere, these rules won't apply, so it might be an option to add further configuration instruciton in the "getting started" documentation files. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent 49fe174 commit 2c35ac2

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extend-exclude = [
3434
extend-include = ["tools/cc1"]
3535
line-length = 99
3636
target-version = "py38"
37+
builtins = ["ptr", "ptr8", "ptr16", "ptr32", "uint", "micropython", "const"]
3738

3839
[tool.ruff.lint]
3940
exclude = [ # Ruff finds Python SyntaxError in these files

0 commit comments

Comments
 (0)