Skip to content

Commit d971bfd

Browse files
committed
docs: Update CONTRIBUTING.md linting section and add daplink_bridge scope.
1 parent 9df5bd3 commit d971bfd

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ lib/<component>/
2828
## Coding conventions
2929

3030
- **Constants**: use `from micropython import const` wrapper in `const.py` files.
31+
- **Imports**: explicit imports only (`from <module>.const import NAME1, NAME2`). Wildcard `import *` is not allowed.
3132
- **Naming**: `snake_case` for all methods and variables. Enforced by ruff (N802, N803, N806).
3233
- **Class inheritance**: `class Foo(object):` is the existing convention.
3334
- **Time**: use `from time import sleep_ms` (not `utime`, not `sleep()` with float seconds).
34-
- **Exceptions**: use `except Exception:` instead of bare `except:`.
35-
- **No debug `print()`** in production driver code.
35+
- **Exceptions**: use `except Exception:` instead of bare `except:`. Enforced by ruff (E722).
36+
- **No debug `print()`** in production driver code. Enforced by ruff (T20, examples and tests excluded).
3637

3738
## Driver API conventions
3839

@@ -58,6 +59,35 @@ To automatically fix issues:
5859
make lint-fix
5960
```
6061

62+
### Active ruff rules
63+
64+
The full configuration is in `pyproject.toml`. Here is a summary of the active rule groups:
65+
66+
| Group | Description |
67+
|-------|-------------|
68+
| A | Prevent shadowing Python builtins |
69+
| B | Flake8-bugbear: common bug patterns |
70+
| C4 / C90 | Comprehension style / McCabe cyclomatic complexity |
71+
| E / W | Pycodestyle errors and warnings |
72+
| F | Pyflakes (unused imports, undefined names, etc.) |
73+
| I | Import sorting (isort) |
74+
| N802, N803, N806 | PEP 8 naming: functions, arguments, and variables must be `snake_case` |
75+
| PL | Pylint (complexity thresholds: max-branches=25, max-statements=65, max-args=10) |
76+
| PERF | Perflint: performance anti-patterns |
77+
| SIM | Flake8-simplify: code simplification suggestions |
78+
| T20 | No `print()` in production code (excluded for examples and tests) |
79+
| RUF | Ruff-specific rules |
80+
81+
### MicroPython-specific exceptions
82+
83+
Some rules are ignored because MicroPython does not support the corresponding Python features:
84+
85+
| Ignored rule | Reason |
86+
|--------------|--------|
87+
| SIM105 | `contextlib.suppress` is not available in MicroPython |
88+
| PIE810 | MicroPython does not support passing tuples to `.startswith()` / `.endswith()` |
89+
| SIM101 | `isinstance()` with merged tuple arguments is unreliable in MicroPython |
90+
6191
## Commit messages
6292

6393
Commit messages follow the [Conventional Commits](https://www.conventionalcommits.org/) format, enforced by commitlint via a git hook:
@@ -70,7 +100,7 @@ Commit messages follow the [Conventional Commits](https://www.conventionalcommit
70100

71101
**Scopes** (optional but enforced): if provided, the scope **must** be one of the allowed values. The scope is recommended for driver-specific changes but can be omitted for cross-cutting changes.
72102

73-
- Driver scopes: `apds9960`, `bme280`, `bq27441`, `daplink_flash`, `gc9a01`, `hts221`, `im34dt05`, `ism330dl`, `lis2mdl`, `mcp23009e`, `ssd1327`, `steami_config`, `vl53l1x`, `wsen-hids`, `wsen-pads`
103+
- Driver scopes: `apds9960`, `bme280`, `bq27441`, `daplink_bridge`, `daplink_flash`, `gc9a01`, `hts221`, `im34dt05`, `ism330dl`, `lis2mdl`, `mcp23009e`, `ssd1327`, `steami_config`, `vl53l1x`, `wsen-hids`, `wsen-pads`
74104
- Domain scopes: `ci`, `docs`, `style`, `tests`, `tooling`
75105

76106
### Examples

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
'apds9960',
1717
'bme280',
1818
'bq27441',
19+
'daplink_bridge',
1920
'daplink_flash',
2021
'gc9a01',
2122
'hts221',

0 commit comments

Comments
 (0)