Qualified annotation httpx.Response binds to unrelated local class _Response (EXTRACTED, 1.0)
Version: graphifyy 0.9.83, graphify update .
What happens
A Python annotation with a qualified external type, httpx.Response, gets a references edge to an unrelated local class named _Response in a test file. The edge is tagged EXTRACTED with confidence 1.0, although the code never mentions that class.
Minimal repro
app/client.py
import httpx
def read_body(response: httpx.Response) -> bytes:
return response.content
tests/test_fake.py
class _Response:
"""Stand-in for a urllib response."""
def read(self):
return b""
Run graphify update .. The graph then contains:
app_client_read_body --references--> tests_test_fake_response EXTRACTED 1.0 ast L4
Expected
No edge, or an edge to an external httpx.Response node. The httpx. qualifier means the annotation cannot name the local class.
Likely cause
From reading the source (not verified with a patch): the annotation resolver appears to discard the qualifier (engine.py, around lines 112-116). The stub-rewiring step then strips leading underscores when it matches labels (extract.py, around lines 3456 and 3478), so Response and _Response compare equal and the one unique local definition is chosen.
Impact
It creates false dependencies from production code to test code and presents them as certain, so impact analysis (graphify affected, query) can mislead.
Thanks for opening this issue, @mattgdrums-cloud. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
Fixed in 0.9.84 (now on PyPI). A qualified external annotation (httpx.Response) no longer binds to an unrelated private local class (_Response). The stub-rewire match key stripped all non-alphanumeric characters, including underscores, so _Response and Response collapsed to the same key; it now preserves underscores, so they are distinct identifiers (Foo() still matches Foo). Thanks for the precise repro and root-cause pointer, @mattgdrums-cloud.