Skip to content

hacktoolkit/flake8-htk-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flake8-htk-rules

Hacktoolkit Flake8 rules for structured Python code, datetime clarity, debugger prevention, and naming precision.

Installation

pip install flake8-htk-rules

For local development:

python -m pip install -e ".[dev]"
python -m unittest discover -s tests -v

Rules

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.

Flake8 Configuration

Enable the rules:

[flake8]
select = SP,DT,DB,NM
structured-programming-files =
    accounts/services.py
    accounts/view_helpers.py
    accounts/views.py

Or combine with existing checks:

[flake8]
extend-select = SP,DT,DB,NM
structured-programming-files =
    accounts/services.py
    accounts/view_helpers.py
    accounts/views.py

The 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.

Development

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages