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

Add ReadOnly support for TypedDicts #17644

Merged
merged 10 commits into from
Sep 30, 2024
Merged

Add ReadOnly support for TypedDicts #17644

merged 10 commits into from
Sep 30, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Aug 5, 2024

Refs #17264

I will add docs in a separate PR.

@sobolevn sobolevn mentioned this pull request Aug 5, 2024
8 tasks

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good, I have few questions and suggestions.

mypy/checkexpr.py Outdated Show resolved Hide resolved
mypy/errors.py Outdated Show resolved Hide resolved
mypy/join.py Outdated Show resolved Hide resolved
mypy/plugins/default.py Show resolved Hide resolved
mypy/typeshed/stdlib/turtle.pyi Outdated Show resolved Hide resolved
test-data/unit/check-typeddict.test Outdated Show resolved Hide resolved
test-data/unit/check-typeddict.test Show resolved Hide resolved
@sobolevn
Copy link
Member Author

sobolevn commented Aug 14, 2024

I ended up with to_be_mutated property for an extra check from .update plugin to check_typeddict_call_with_kwargs (the only place where we can really do this check). It is not the nicest solution, but it seems good enough.

@ilevkivskyi thanks a lot for your review! You found several bugs that I've missed. Please, take a look again, once you have the time :)

This comment has been minimized.

@EwoutH
Copy link

EwoutH commented Aug 26, 2024

Thanks a lot for this effort!

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

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

Thanks for updates. I think it is worth adding some incremental and/or fine grained tests. Feel free to merge when you feel you added enough.

Copy link
Contributor

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

@sobolevn sobolevn merged commit 6726d77 into master Sep 30, 2024
20 checks passed
@sobolevn sobolevn deleted the typeddict-readonly branch September 30, 2024 11:41
@sobolevn
Copy link
Member Author

I've added a test case for the fine-grained mode. Thanks a lot for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants