Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/plugins/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def _add_attrs_magic_attribute(
ctx.cls,
MAGIC_ATTR_NAME,
TupleType(attributes_types, fallback=attributes_type),
fullname=f"{ctx.cls.fullname}.{attr_name}",
fullname=f"{ctx.cls.fullname}.{MAGIC_ATTR_NAME}",
override_allow_incompatible=True,
is_classvar=True,
)
Expand Down
34 changes: 34 additions & 0 deletions test-data/unit/fine-grained-attr.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,37 @@ A.__attrs_attrs__.b

[out]
==

[case magicAttributeConsistency2-only_when_cache]
[file c.py]
import attr

@attr.s
class Entry:
var: int = attr.ib()
[builtins fixtures/attr.pyi]

[file m.py]
from typing import Any, ClassVar, Protocol
from c import Entry

class AttrsInstance(Protocol):
__attrs_attrs__: ClassVar[Any]

def func(e: AttrsInstance) -> None: ...
func(Entry(2))

[file m.py.2]
from typing import Any, ClassVar, Protocol
from c import Entry

class AttrsInstance(Protocol):
__attrs_attrs__: ClassVar[Any]

def func(e: AttrsInstance) -> int:
return 2 # Change return type to force reanalysis

func(Entry(2))

[out]
==