-
Notifications
You must be signed in to change notification settings - Fork 14
/
pyproject.toml
160 lines (129 loc) · 5.4 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
[tool.codespell]
count = ""
ignore-regex = '\b[A-Z]{3}\b'
ignore-words-list = "ans,asend,deques,dout,extint,hsi,iput,mis,numer,shft,technic,ure"
quiet-level = 3
skip = """
*/build*,\
./.git,\
./.gitattributes,\
./.gitignore,\
./.gitmodules,\
./LICENSE,\
./esp-idf,\
./MicroHydra,\
./MicroPython,\
./src/font,\
"""
[tool.pyright]
# Ruff is handling most of this stuff, so we'll supress some of pyrights warnings.
include = [
"./src",
"./devices",
"./tools",
]
exclude = [
"./src/font",
]
ignore = ["*"]
[tool.ruff]
# Exclude third-party code from linting and formatting
extend-exclude = ["esp-idf", "./MicroHydra", "MicroPython", "src/font"]
line-length = 120
target-version = "py39"
# Add micropython-specific (and viper-specific) built-in names
builtins = ["const", "micropython", "ptr", "ptr8", "ptr16", "ptr32"]
[tool.ruff.lint]
# These linting rules are new and likely to change.
# If you have any suggestions, please feel free to share!
# Currently, linting rules are being selected by just enabling "ALL" and then disabling
# any that don't work well for us. However this might not be the most elegant strategy,
# and might need to be changed in the future.
# Select all stable linting rules.
select = ["ALL"]
# Ignore every rule that doesn't work for us:
ignore = [
# These exclusions are borrowed from the MicroPython repo:
"E401", # Multiple imports on one line
"E402", # Module level import not at top of cell
"E722", # Do not use bare except
"E731", # Do not assign a lambda expression, use a def
"E741", # Ambiguous variable name
"F401", # imported but unused
"F403", # `from {name} import *` used
"F405", # {name} may be undefined, or defined from star imports
# These exclusions just arent really relevant (or don't work) in MicroPython:
"PLC1901", # compare-to-empty-string
"FURB101", # open and read should be replaced by Path({filename})
"FURB103", # open and write should be replaced by Path({filename})
"PLW1514", # unspecified-encoding
"FBT003", # boolean-positional-value-in-call
"PIE810", # Call {attr} once with a tuple (str.startswith/endswith)
"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
"FA", # flake8-future-annotations
"PLW2901", # redefined-loop-name (Limited resources)
"ANN0", # Missing type annotations (No Typing module)
"ANN204", # Missing return type annotation for special method
"PTH", # Use pathlib (No pathlib module)
"INP001", # File is part of an implicit namespace package. (Just a bit unnecessary)
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF005", # collection-literal-concatenation
"FBT001", # A function taking a sinlge bool value is very common.
# MH uses commented out code in the build process:
"ERA", # Found commented-out code
# This is kinda unstable and also breaks hydra conditionals sometimes.
"I001", # Import block is un-sorted or un-formatted
# for now, MH takes a soft approach to quote-style.
# You should just try to maintain consistency with surrounding code:
"Q000", # Single quotes found but double quotes preferred
# Up for debate, but IMO a bit of extra space really helps with dense code blocks:
"E303", # Too many blank lines
"D202", # No blank lines allowed after function docstring
# MH specifically allows the use of tabs over spaces in its code for accessibility.
# (And spaces are allowed because they are usually the editor default):
"D206", # Docstring should be indented with spaces, not tabs
"W191", # Indentation contains tabs
# This can sometimes harm performance in MP:
"FURB136", # Replace if expression with {min_max} call
"PLR1730", # ^
# PEP8 reccomends grouping by order-of-operations
# like: `4*6 + 12*2`
"E226", # Missing whitespace around arithmetic operator
# This is highly opinionated, but IMO if you are doing this,
# you're probably trying to make the code more readable:
"E702", # Multiple statements on one line (semicolon)
"E701", # Multiple statements on one line (colon)
# This rule is great for the most part, but there are far too many
# valid exceptions to the rule to this rule in the MH source:
"PLR2004", # Magic value used in comparison
# These are just kinda overkill:
"D105", # Missing docstring in magic method
"T201", # `print` found
# This is a good suggestion, but it pops up too often when a trailing comma will actually break something
"COM812", # missing-trailing-comma
]
[tool.ruff.lint.pep8-naming]
# Allow _CONSTANT naming in functions
# ("_" followed by a capital letter, then any other characters, will be ignored)
extend-ignore-names = ["_[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*"]
[tool.ruff.lint.mccabe]
# Some MicroPython code unfortunately must be somewhat complex for speed reasons.
max-complexity = 40
[tool.ruff.lint.per-file-ignores]
# manifest.py files are evaluated with some global names pre-defined
"**/manifest.py" = ["F821"]
[tool.ruff.lint.isort]
# Use 2 lines after imports
lines-after-imports = 2
[tool.ruff.lint.pylint]
# for speed reasons, assigning to a var isn't always worth it
max-bool-expr = 20
# Similarly, some MH functions just need lots of args
max-args = 10
# The default value of 6 is too restrictive (It even flags CPython builtins!)
max-returns = 10
[tool.ruff.lint.flake8-annotations]
suppress-none-returning = true
[tool.ruff.lint.pydocstyle]
# Use pep257 docstrings.
convention = "pep257"