-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
unittest.mock.Mock is not treated as Any in strict mode #6136
Comments
…s that derives from `Any`. Previously, these were evaluated as `Unknown`, but they are now evaluated as `Any`. This is related to #6136.
The type declaration for Currently, when accessing an attribute from a class that derives from c1: Any = 1
reveal_type(c1.foo) # Any
class DerivesFromAny(Any): ...
c2 = DerivesFromAny()
reveal_type(c2.foo) # Unknown I think it makes sense to change this behavior for consistency. This will be addressed in the next release. |
This is included in pyright 1.1.332, which I just published. It will also be included in a future release of pylance. |
Thanks for the quick resolution! |
As far as I know,
Mock
objects should be treated asAny
by type checkers (see e.g. #3611). However, the following code raises type warnings in strict mode.The errors are
And if this should be the expected behavior, what is the correct way to work with mock functions like
assert_not_called
?Tested with pyright 1.1.331 on the command line.
The text was updated successfully, but these errors were encountered: