Skip to content

Fix __post_init__() internal error#16080

Merged
sobolevn merged 4 commits into
python:masterfrom
ikonst:fix-16057
Sep 10, 2023
Merged

Fix __post_init__() internal error#16080
sobolevn merged 4 commits into
python:masterfrom
ikonst:fix-16057

Conversation

@ikonst

@ikonst ikonst commented Sep 9, 2023

Copy link
Copy Markdown
Contributor

Fixes #16057.

@ikonst

ikonst commented Sep 9, 2023

Copy link
Copy Markdown
Contributor Author

👋 @sobolevn as author of #15503

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe add a test?

Comment thread mypy/nodes.py
# 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.

@ikonst

ikonst commented Sep 9, 2023

Copy link
Copy Markdown
Contributor Author

btw, repro is even simpler 🤦

def __post_init__() -> None:
    pass

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Sep 9, 2023

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sobolevn sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

__post_init__() causes INTERNAL ERROR

3 participants