Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tune dermestes

All configuration lives in [tool.dermestes] in pyproject.toml.

[tool.dermestes]
exclude = ["migrations/**"]
test-paths = ["tests/**", "test_*.py", "*_test.py", "conftest.py"]
ignore-decorators = ["functools.cache"]
public = ["src/mypkg/api/**"]
disable = ["one-impl"]
  • exclude: files never indexed, for vendored or broken code. Their calls do not count. examples/**, docs/** and **/test/resources/** are different, whatever exclude says: indexed, so their calls vary a parameter and make a wrapper documented API, but never reported, since there the explicit parameter is the lesson.
  • test-paths: files whose code is counted as tests, never as targets.
  • ignore-decorators: decorators that no longer exempt a function from const-param, forward pass-through or dead-code, by dotted name or suffix (cache covers functools.cache).
  • public: globs treated as public API and exempt.
  • disable: check ids to skip.

Suppression is per definition, on any line of its header (decorators through the closing :), with a mandatory reason: # dermestes: keep <reason>.

Always exempt, whatever the config: test code, generated files (Do not edit or DO NOT EDIT in the first 5 lines), names in __all__, names re-exported from an __init__.py, dunder methods (const-param checks __init__), ABCs passed to X.register(...), and any name passed as a string to getattr, setattr, hasattr, patch or patch.object (a dotted path counts by its last part), or used as a string key in a registry dict ({"csv": CsvExporter}). Docstrings and string type annotations do not count.

All but one-impl also exempt decorated functions (unless ignore-decorators lists every decorator), functions used as a value anywhere (register(f), x.f without a call), overrides, abstract and Protocol methods, functions called only under if __name__ == "__main__":, and every function of a module or class getattr reads a computed name from. const-param also exempts constants a test patches; pass-through also exempts functions named in [project.scripts] or [project.entry-points] of any pyproject.toml, anything a test calls, and any private name a test spells as a whole string ("_load"). Suppress a deliberate wrapper with keep, or disable = ["pass-through"].

dead-code counts mentions, not calls: any identifier or attribute with the name, a string spelling it, or the word in any non-.py file (a template, TOML, Markdown), docs/ and examples/ included. It also exempts entry points, Alembic upgrade/downgrade, _repr_*_ hooks, and public names in a package that ships py.typed.

A library’s public functions are called from outside the repository. List their modules in public rather than keeping each one.

next: run dermestes --all