Skip to content

Commit fdc7914

Browse files
committed
Fix __post_init__() internal error
1 parent 4941983 commit fdc7914

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

mypy/checker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,8 @@ def check_func_item(
10761076

10771077
if name == "__exit__":
10781078
self.check__exit__return_type(defn)
1079+
# TODO: the following logic should move to the dataclasses plugin
1080+
# https://github.com/python/mypy/issues/15515
10791081
if name == "__post_init__":
10801082
if dataclasses_plugin.is_processed_dataclass(defn.info):
10811083
dataclasses_plugin.check_post_init(self, defn, defn.info)

mypy/nodes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ def __init__(self) -> None:
515515
# Original, not semantically analyzed type (used for reprocessing)
516516
self.unanalyzed_type: mypy.types.ProperType | None = None
517517
# If method, reference to TypeInfo
518-
# TODO: Type should be Optional[TypeInfo]
519518
self.info = FUNC_NO_INFO
520519
self.is_property = False
521520
self.is_class = False

mypy/plugins/dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,8 +1070,8 @@ def replace_function_sig_callback(ctx: FunctionSigContext) -> CallableType:
10701070
)
10711071

10721072

1073-
def is_processed_dataclass(info: TypeInfo | None) -> bool:
1074-
return info is not None and "dataclass" in info.metadata
1073+
def is_processed_dataclass(info: TypeInfo) -> bool:
1074+
return info and "dataclass" in info.metadata
10751075

10761076

10771077
def check_post_init(api: TypeChecker, defn: FuncItem, info: TypeInfo) -> None:

0 commit comments

Comments
 (0)