-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
monkeypatch: add support for TypedDict #11000
monkeypatch: add support for TypedDict #11000
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for this excellent addition
lets add type triggers in https://github.com/pytest-dev/pytest/blob/main/testing/typing_checks.py as well to make sure type checks work as expected
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
pre-commit errors are because TypedDict doesn't exist in 3.7. Solutions include bumping |
We just merge a pr to remove the default version,, does that help? |
The current approach wouldn't work; So some other approach is needed. Off hand I'm not sure how to refer to all typed dicts. Maybe the solution is to relax the |
See python/mypy#4976. Particularly the current last comment python/mypy#4976 (comment) matches the case here. |
I'd be fine with the Mapping solution if you want me to implement that. |
for more information, see https://pre-commit.ci
Confirmed that this solves the problem for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK there is no type-safe way to do this in current python, so Mapping
sounds OK to me -- for the monkeypatch
use case, some type unsafety seems better than forcing users to cast or type-ignore.
I left some comments.
Co-authored-by: Ran Benita <ran@unusedvar.com>
Seems like |
We will need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Closes #10999
This feature was added in Python 3.8. It looks like pytest still supports Python 3.7 (I'm guessing that will change in about 6 weeks). For now, it isn't easy to test or annotate this properly.