Hacktoolkit Flake8 rules for structured Python code, datetime clarity, debugger prevention, and naming precision.
pip install flake8-htk-rulesFor local development:
python -m pip install -e ".[dev]"
python -m unittest discover -s tests -v| Code | Description |
|---|---|
SP100 |
Functions in configured files should prefer a single return statement. |
SP101 |
Return values in configured files should be simple variables, attributes, literals, or bare returns. |
DT100 |
Use import datetime instead of from datetime import datetime. |
DT101 |
Use import datetime instead of from datetime import date. |
DT102 |
Use import datetime instead of from datetime import timedelta. |
DB100 |
Do not commit debugger imports such as import pdb or from pdb import set_trace. |
DB101 |
Do not commit debugger calls such as breakpoint() or pdb.set_trace(). |
NM100 |
Avoid the vague get_ function or method prefix; choose a more precise verb. |
Enable the rules:
[flake8]
select = SP,DT,DB,NM
structured-programming-files =
accounts/services.py
accounts/view_helpers.py
accounts/views.pyOr combine with existing checks:
[flake8]
extend-select = SP,DT,DB,NM
structured-programming-files =
accounts/services.py
accounts/view_helpers.py
accounts/views.pyThe SP rules are gated by structured-programming-files so teams can roll them
out on a targeted set of modules. The DT, DB, and NM rules are always
active when selected.
The plugin uses a single Flake8 entry point and delegates rule logic to
family modules under src/flake8_htk_rules/checks/. Add new rule families
there and cover them in tests/.
Run the test suite without installing the package:
PYTHONPATH=src python -m unittest discover -s tests -v