{"id":23527,"library":"dead","title":"dead","description":"Dead simple Python dead code detection. Current version 2.1.0 (released 2024-12-08). Checks for unused functions, classes, variables, and imports. Release cadence is irregular, typically a few times a year. Compatible with Python >=3.9.","status":"active","version":"2.1.0","language":"python","source_language":"en","source_url":"https://github.com/asottile/dead","tags":["dead-code","linter","code-quality","python"],"install":[{"cmd":"pip install dead","lang":"bash","label":"Install dead"}],"dependencies":[{"reason":"File pattern matching (gitignore style)","package":"pathspec","optional":false},{"reason":"Optional config file parsing","package":"pyyaml","optional":true},{"reason":"Optional TOML config parsing (Python <3.11)","package":"tomli","optional":true}],"imports":[{"note":"Old internal path; breaks in 2.x","wrong":"from dead.dead import DeadCodeChecker","symbol":"DeadCodeChecker","correct":"from dead import DeadCodeChecker"}],"quickstart":{"code":"# Install: pip install dead\n# Basic usage: dead .\n# Always check file list first:\nimport subprocess\nimport sys\n\n# Run from command line, not import\ncmd = [sys.executable, '-m', 'dead', '--', '.']\nsubprocess.run(cmd, check=True)","lang":"python","description":"Run dead via command line. There is no stable Python API; use subprocess."},"warnings":[{"fix":"Update CLI calls: replace '--exclude' with '--ignore'. Remove any direct Python imports of dead internals.","message":"Version 2.x is a complete rewrite. CLI arguments changed: no more -v/--verbose, --exclude replaced by --ignore. Module structure changed: 'from dead.dead import DeadCodeChecker' no longer works. Direct import of dead from Python is not supported as a library; use subprocess.","severity":"breaking","affected_versions":"1.x -> 2.x"},{"fix":"Use dead as a quick check but complement with mypy's --unused-ignore or pyright's unused expression checks for deeper analysis.","message":"dead only detects *truly unused* symbols in the current project scope. It does not detect unused *exports* intended for external consumers (library code). It may also miss unused symbols behind conditional imports or dynamic access.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace '--min-version' with '--target-version'.","message":"The '--min-version' flag is deprecated in 2.x and will be removed in a future release. Use '--target-version' instead.","severity":"deprecated","affected_versions":"2.0.0+"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Remove any direct imports of dead internals. Run dead only via CLI: python -m dead .","cause":"Breaking change in 2.0: the internal module was reorganized. 'dead.dead' no longer exists.","error":"ModuleNotFoundError: No module named 'dead.dead'"},{"fix":"Use '--ignore' instead of '--exclude' when specifying patterns to skip.","cause":"The '--exclude' flag was renamed to '--ignore' in version 2.0.","error":"usage: dead [-h] [--ignore pattern] [paths ...]\ndead: error: unrecognized arguments: --exclude"},{"fix":"Check the reported file for syntax errors. If using f-strings or other features unsupported by older Python versions, ensure your code is valid Python 3.9+.","cause":"dead requires Python >=3.9 and may parse files with syntax errors (unrelated to Python version). It will report syntax errors for files it cannot parse.","error":"SyntaxError: invalid syntax"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}