-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow objects matching SupportsKeysAndGetItem
to be unpacked
#14990
Allow objects matching SupportsKeysAndGetItem
to be unpacked
#14990
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@hauntsaninja I've got all but one unit test passing and the problem isn't obvious to me: The test reports that b, c, d, e, f, g, and h are all stale, so I've tried changing line 1300 to |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/infrastructure/process.py:235: error: List item 0 has incompatible type "object"; expected "Mapping[<nothing>, <nothing>]" [list-item]
+ src/prefect/infrastructure/process.py:235: error: List item 0 has incompatible type "object"; expected "SupportsKeysAndGetItem[<nothing>, <nothing>]" [list-item]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_make_custom_builds.py:299: error: List item 0 has incompatible type "Optional[DataclassOptions]"; expected "Mapping[Any, Any]" [list-item]
+ src/hydra_zen/structured_configs/_make_custom_builds.py:299: error: List item 0 has incompatible type "Optional[DataclassOptions]"; expected "SupportsKeysAndGetItem[Any, Any]" [list-item]
|
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, this looks great!
I don't understand what's going on with testAddModuleAfterCache3
an don't understand why adding two files fixes. But the core logic here seems good and unit tests should fail if typeshed ever makes enough changes that e.g. the protocol no longer exists or _typeshed is not in the builtins scc or whatever
Fixes #14986
This PR allows any object matching
_typeshed.SupportsKeysAndGetItem[str, Any]
to be unpacked with**
.