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

Improve the first overload of is_dataclass #9758

Merged
merged 3 commits into from
Feb 19, 2023
Merged

Conversation

AlexWaygood
Copy link
Member

Fixes #9723. I think this is the best compromise for now.

@github-actions
Copy link
Contributor

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

Comment on lines +63 to +70
# Mypy correctly emits an error on these due to the fact
# that it's a dataclass class, not a dataclass instance.
# Pyright, however, handles ClassVar members in protocols differently.
# See https://github.com/microsoft/pyright/issues/4339
#
# dc.asdict(x)
# dc.astuple(x)
# dc.replace(x)
Copy link
Member Author

Choose a reason for hiding this comment

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

We could possibly put these tests inside an if MYPY block, and add "defineConstant": { "MYPY": false } } to our pyrightconfig file for our test cases, to ensure that pyright doesn't check any code inside if MYPY blocks. I'm sort-of wary of doing that, however, as I'd really like to keep typechecker-specific test cases to a minimum in typeshed.

@JelleZijlstra JelleZijlstra merged commit 4ca0c48 into main Feb 19, 2023
@JelleZijlstra JelleZijlstra deleted the dataclasses-improve branch February 19, 2023 14:26
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.

Repair is_dataclass definition?
2 participants