Contributing
Create a feature branch from main, open a pull request targeting main, and
wait for review. Do not commit feature changes directly to main; release
commits are made by the maintainer on main.
make check- runs unit tests and other checks using virtual environment.make test- runs the test suite in parallel withpytest-xdist, using one worker per logical CPU minus one. SetPYTEST_XDIST_WORKERSto change the worker count (make test PYTEST_XDIST_WORKERS=2), or passPYTEST_ME_PLEASE="-n 0"to run serially.
Enhancement proposals
A change that adds an analyser feature, changes rule semantics, or changes a documented process needs a Deadcode Enhancement Proposal (DEP).
The published process and template page is https://deadcode.readthedocs.io/en/stable/dep.html. The repository index of existing proposals is
enhancement_proposals/dep_0.md.
Security
The runtime dependencies in requirements.txt and the development dependencies in requirements-dev.txt are audited for known
vulnerabilities with pip-audit. The Vulnerability audit workflow in .github/workflows/vulnerability-audit.yml runs on every pull request,
on every push to main, and weekly on a schedule. Run the same audit locally with make audit, make audit-runtime, or
make audit-development.
Read the security documentation for how to read and fix a finding. The only accepted
exception is filelock==4.1.0 on Python 3.10, where the fix requires Python 3.11 or newer.
Enhancement proposals
A change that adds an analyser feature, changes rule semantics, or changes a documented process needs a Deadcode Enhancement Proposal (DEP).
Read the Deadcode Enhancement Proposals (DEPs) page for the DEP process and template, and enhancement_proposals/dep_0.md for the index of existing proposals.
Feature requests
A checked entry is implemented on main and is included in the next release; published releases may lag behind main.
[x] Replace
.*with only*in regexp matching.[x] Add unused class method detection DC04 check.
[x] Add
--fixoption to automatically remove detected dead code occourencies[x] Add a check for empty python files.
[x] Split error codes into DC01, DC02, DC03 for variables, functions, class.
[x] Should have different codes for ignoring name and ignoring whole definition (reserved DCxx0 - ignore name, DCxx1 - ignore definition).
[ ] Allow to disable each check separately using:
[ ] inline comment.
[ ] pyproject.toml file
[x] Add a check for code in comments.
[x] DC06: detect an unused name.
[x] DC09: report an unreachable body, e.g. an
iforwhileblock that cannot run.[ ] Add target python version option, if specified it will be used for code base check.
[ ] Add a
--depthparameter to ignore nested code.. (To only check global scope use 0).[ ] Add options:
[x] –ignore-definitions
[x] –ignore-definitions-if-inherits-from
[x] –ignore-definitions-if-decorated-with
[x] –ignore-names-if-inherits-from
[x] –ignore-names-if-decorated-with
[x] –ignore-bodies-of
[x] –ignore-bodies-if-decorated-with
[x] –ignore-bodies-if-inherits-from
Question: would it be possible to ignore only certain types of checks for a body, e.g. only variable attributes of TypedDict and still check usage of methods and properties?
What expression would allow this type of precission?
[ ] Distinguish between definitions with same name, but different files.
[ ] Repeated application of
deadcodetill the output stops changing.[x] Unreachable code detection and fixing: this should only be scoped for if statements and only limited to primitive variables.
[ ] Benchmarking performance with larger projects (time, CPU and memory consumption) in order to optimize.
[ ]
--fixcould accept a list of filenames as well (only those files would be changed, but the summary could would be full). (This might be confusing, because filenames, which have to be considered are provided without any flag, –fix is expected to not accept arguments)[ ] pre-commit-hook.
[ ] language server.
[x] DC13: remove code after terminal statements like
raise,return,break,continueand comes in the same scope.[ ] Add
ignoreandper-file-ignorescommand line and pyproject.toml options, which allows to skip some rules.[ ] Make sure that all rules are being skipped by
noqacomment and all rules react tonoqa: rule_idcomments.[ ] Include package names into code item scope (dot-separated path), e.g. “package1.package2.module.class.method.variable”.
[ ] All options should be able to accept dot-separated path or a generic name, e.g. “marshmallow.Schema” vs “Schema”, documentation should cleary demonstrate the behaviour/example that “Schema” means “*.Schema”.
[ ] Redefinition of an existing name makes previous name unreachable, unless it is assigned somehow.
[ ] Check if file is still valid/parsable after automatic fixing, if not: halt the change and report error.
[ ] Investigate ways of extracting and backporting Python3.10+
astimplementation to lower Python versions.