Skip to content

Commit b82db50

Browse files
committed
change getattr -> .plugin_generated && fix nodes.py
1 parent 6382550 commit b82db50

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

mypy/nodes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ class FuncDef(FuncItem, SymbolNode, Statement):
800800
"dataclass_transform_spec",
801801
"docstring",
802802
"deprecated",
803+
"plugin_generated",
803804
)
804805

805806
__match_args__ = ("name", "arguments", "type", "body")
@@ -812,6 +813,7 @@ def __init__(
812813
body: Block | None = None,
813814
typ: mypy.types.FunctionLike | None = None,
814815
type_args: list[TypeParam] | None = None,
816+
plugin_generated: bool | None = None,
815817
) -> None:
816818
super().__init__(arguments, body, typ, type_args)
817819
self._name = name
@@ -832,6 +834,7 @@ def __init__(
832834
# the majority). In cases where self is not annotated and there are no Self
833835
# in the signature we can simply drop the first argument.
834836
self.is_trivial_self = False
837+
self.plugin_generated = False
835838

836839
@property
837840
def name(self) -> str:

mypy/plugins/attrs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ def _get_attrs_init_type(typ: Instance) -> CallableType | None | AnyType:
10341034
return None
10351035
# case 1: normal FuncDef
10361036
if isinstance(init_method, FuncDef) and isinstance(init_method.type, CallableType):
1037-
if getattr(init_method, "plugin_generated", False):
1037+
if init_method.plugin_generated:
10381038
return init_method.type
10391039
else:
10401040
return AnyType(TypeOfAny.special_form)

0 commit comments

Comments
 (0)