-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctlytopic-variable-scope
Description
Bug Report
In an attrs class with a field that is named the same as an import, the name-defined
check is whitespace-dependent.
To Reproduce
import httpx
from attrs import define, field
@define
class Foo:
httpx: httpx.AsyncClient = field(
factory=lambda: httpx.AsyncClient()
)
Expected Behavior
This code should type check identically to:
import httpx
from attrs import define, field
@define
class Foo:
httpx: httpx.AsyncClient = field(factory=lambda: httpx.AsyncClient()) # on one line
Actual Behavior
test.py:7: error: Name "httpx.AsyncClient" is not defined [name-defined]
Your Environment
- Mypy version used: 1.17.1
- Python version used: 3.13.6
- attrs version used: 25.3.0
wyattscarpenter
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongsemantic-analyzerProblems that happen during semantic analysisProblems that happen during semantic analysistopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctlytopic-variable-scope