Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix __post_init__() internal error #16080

Merged
merged 4 commits into from
Sep 10, 2023
Merged

Fix __post_init__() internal error #16080

merged 4 commits into from
Sep 10, 2023

Conversation

ikonst
Copy link
Contributor

@ikonst ikonst commented Sep 9, 2023

Fixes #16057.

@ikonst
Copy link
Contributor Author

ikonst commented Sep 9, 2023

👋 @sobolevn as author of #15503

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Maybe add a test?

@@ -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
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
Copy link
Contributor Author

ikonst commented Sep 9, 2023

btw, repro is even simpler 🤦

def __post_init__() -> None:
    pass

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2023

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

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks!

@sobolevn sobolevn merged commit f9dc561 into python:master Sep 10, 2023
17 checks passed
@ikonst ikonst deleted the fix-16057 branch September 10, 2023 11:05
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