Skip to content

feat: add import resolution tracer (pywho trace)#1

Merged
AhsanSheraz merged 3 commits into
mainfrom
feat/import-trace
Mar 15, 2026
Merged

feat: add import resolution tracer (pywho trace)#1
AhsanSheraz merged 3 commits into
mainfrom
feat/import-trace

Conversation

@AhsanSheraz

@AhsanSheraz AhsanSheraz commented Mar 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • New pywho trace <module> subcommand that explains where an import resolves and why
  • Shows sys.path search order, module type (stdlib/third-party/local/builtin), cache status
  • Detects import shadows: warns when local files shadow stdlib or installed packages
  • trace_import() Python API with TraceReport dataclass
  • --verbose flag for full sys.path search log, --json for machine-readable output
  • 21 new tests (53 total), updated README, docs, API reference, CHANGELOG
  • Version bump to 0.2.0

Test plan

  • 53 tests passing locally
  • CI passes on all 3 OSes x 5 Python versions
  • Smoke test: pywho trace json, pywho trace pytest, pywho trace nonexistent
  • Verify shadow detection with a local shadow file

ahsansheraz-bonial and others added 3 commits March 15, 2026 15:22
New `pywho trace <module>` subcommand that explains where an import
resolves and why. Includes sys.path search order, module classification,
cache detection, and shadow warnings.

- tracer.py: core trace engine with trace_import() API
- trace_formatter.py: colored terminal output for trace reports
- CLI: `pywho trace <module>` with --verbose and --json flags
- 21 new tests (53 total)
- Updated README, docs, API reference, and CHANGELOG
- Version bump to 0.2.0
On macOS system Python, site-packages lives under the same prefix as
stdlib. Check for 'site-packages' in origin path first to correctly
classify third-party packages on all platforms.
@AhsanSheraz AhsanSheraz merged commit 0b628bb into main Mar 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants