Skip to content

fix(discovery): setuptools build output (build/lib) analyzed as project code #159

Description

@rahlk

Plan (optional)

None — small scoping fix.

Problem

File discovery (codeanalyzer/core.py ~line 870) walks project_dir.rglob("*.py") and skips only site-packages, .venv, and .codeanalyzer path parts. A project built with setuptools carries build/lib/** — byte copies of its package sources — so every module is analyzed twice (once under its real path, once under build/lib/...), inflating the symbol table and downstream graphs. Same bug class just fixed in codeanalyzer-java, where Gradle's build/resources copies of test fixtures leaked into analysis (codellm-devkit/codeanalyzer-java#199); found during that fix's propagation sweep. dist/ (sdist/wheel staging) and *.egg-info are worth the same look.

Scope boundary

Discovery filter only. No schema change, no change to what a module contains — only which files become modules.

Goals

  • build/lib (and dist, *.egg-info if confirmed) excluded from discovery
  • Failing test first: fixture with a build/lib copy of a real module yields one module, not two

Caveats and known risks

  • A project with hand-written sources under a top-level build/ package would lose them — accepted, collides with setuptools' own output convention.

Definition of done

  • Test fails before / passes after; module count over the fixture equals the hand-counted set
  • Full test suite green

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions