-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Make type of unitest.mock.Any
a subclass of Any
#14708
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
Conversation
Another approach suggested by @srittau is having |
This comment has been minimized.
This comment has been minimized.
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.
Open to exploring subclass with Any! Might be better, but only real world code examples I can think of where it matters are a little contrived.
stdlib/unittest/mock.pyi
Outdated
@@ -513,7 +513,8 @@ class _ANY: | |||
def __ne__(self, other: object) -> Literal[False]: ... | |||
__hash__: ClassVar[None] # type: ignore[assignment] | |||
|
|||
ANY: _ANY | |||
# See https://github.com/python/typeshed/issues/14701 | |||
ANY: Any |
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.
Do we need class _Any
above?
if it's a working solution, I think a subclass of Any is preferable, given that:
|
This comment has been minimized.
This comment has been minimized.
LGTM, although we could add some tests to ensure that the problem mentioned in #14701 is fixed. Also, the example from the docs seems worthwhile to add as a test. |
mock.ANY
changesunitest.mock.Any
a subclass of Any
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Closes: #14701