From 4c880c95ee016d7bcb1d06317e068fbbeede091a Mon Sep 17 00:00:00 2001 From: DevForge Engineer Date: Mon, 18 May 2026 04:15:23 -0400 Subject: [PATCH] fix: add __main__.py for python -m deadcode support, update changelog and package.json metadata - Add src/deadcode/__main__.py entry point so 'python -m deadcode' works - Update CHANGELOG.md with 0.1.1 release notes - Fix package.json description (said 'Python projects' but tool targets TS/React) - Clean up dead no-op assertion in test_scan_category_filter --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- src/deadcode/__main__.py | 5 +++++ tests/test_scanner.py | 6 +++--- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/deadcode/__main__.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0df2342..e8bacd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.1] - 2026-05-18 + +### Added +- `__main__.py` module for `python -m deadcode` support + +### Fixed +- CLI no longer fails when invoked via `python -m deadcode` + ## [0.1.0] - 2025-05-17 ### Added diff --git a/package.json b/package.json index a681f71..41aca33 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "deadcode-cli", "version": "0.1.0", - "description": "Find unused/dead code in Python projects. Static analysis tool to identify orphaned functions, classes, and imports.", + "description": "Detect and remove unused exports, dead routes, orphaned CSS, and unreferenced components in TypeScript/React/Next.js projects.", "author": "Revenue Holdings ", "license": "MIT", "repository": { diff --git a/src/deadcode/__main__.py b/src/deadcode/__main__.py new file mode 100644 index 0000000..b5ebbc9 --- /dev/null +++ b/src/deadcode/__main__.py @@ -0,0 +1,5 @@ +"""DeadCode CLI entry point for `python -m deadcode`.""" +from .cli import cli + +if __name__ == "__main__": + cli() diff --git a/tests/test_scanner.py b/tests/test_scanner.py index fc3afd1..331489b 100644 --- a/tests/test_scanner.py +++ b/tests/test_scanner.py @@ -274,9 +274,9 @@ def test_scan_json_output(self, runner, sample_project): def test_scan_category_filter(self, runner, sample_project): result = runner.invoke(cli, ["-p", str(sample_project), "scan", "-c", "orphaned_css"]) assert result.exit_code == 0 - json.loads(result.output) if "--json-output" in [] else None - # Just check it doesn't crash - assert "Orphaned CSS" in result.output or result.exit_code == 0 + # Should only show orphaned CSS findings + assert "Orphaned CSS" in result.output + assert "Unused Exports" not in result.output def test_scan_nonexistent_dir(self, runner): result = runner.invoke(cli, ["-p", "/nonexistent/path", "scan"])