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

Special handling for InitVar #12046 #14299

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Henkhogan
Copy link

@Henkhogan Henkhogan commented Dec 15, 2022

"Fixes #12046"

Supposed to properly handle the case when a dataclass is defined with an InitVar and a property that both have the same name.

I added a test that should cover this case, but did not run the tests locally

@Henkhogan
Copy link
Author

Can someone please advise how to properly resolve

mypy\semanal.py:6586: error: Non-overlapping identity check (left operand type: "Optional[Type]", right operand type: "Type[InitVar[Any]]") [comparison-overlap]
return isinstance(node, Var) and node.type is InitVar

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉



def is_init_only(node: SymbolNode | None) -> bool:
return isinstance(node, Var) and node.type is InitVar
Copy link
Contributor

Choose a reason for hiding this comment

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

node.type is a mypy.types.Type, not a Python type

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.

Error on instance property and init-only variable with the same name in a dataclass
2 participants