Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 0 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,8 @@ def check_func_item(

if name == "__exit__":
self.check__exit__return_type(defn)
# TODO: the following logic should move to the dataclasses plugin
# https://github.com/python/mypy/issues/15515
if name == "__post_init__":
if dataclasses_plugin.is_processed_dataclass(defn.info):
dataclasses_plugin.check_post_init(self, defn, defn.info)
Expand Down
1 change: 0 additions & 1 deletion mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def __init__(self) -> None:
# Original, not semantically analyzed type (used for reprocessing)
self.unanalyzed_type: mypy.types.ProperType | None = None
# If method, reference to TypeInfo
# TODO: Type should be Optional[TypeInfo]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was added in 2018 in #4438.

FakeInfo was added in 2017, and the following comment seems to be at odds:

mypy/mypy/nodes.py

Lines 3366 to 3370 in fdc7914

# 'None' is not used as a dummy value for two reasons:
# 1. This will require around 80-100 asserts to make 'mypy --strict-optional mypy'
# pass cleanly.
# 2. If NOT_READY value is accidentally used somewhere, it will be obvious where the value
# is from, whereas a 'None' value could come from anywhere.

self.info = FUNC_NO_INFO
self.is_property = False
self.is_class = False
Expand Down
4 changes: 2 additions & 2 deletions mypy/plugins/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,8 @@ def replace_function_sig_callback(ctx: FunctionSigContext) -> CallableType:
)


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


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