-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
with
-syntax makes mypy confuse int
with Any
#9750
Comments
You need to annotate |
Thanks! Could you please elaborate here, I don't see any way to annotate […]
class Connection:
def __enter__(self) -> Connection:
return self
[…] …but it makes python complain: |
|
Oh, cool, that does the trick, thank you! |
Bug Report
When an object is declared with
with
syntax, and then a method of that object is called,mypy
thinks that method returnsAny
, even if the method is properly annotated to return something else. Removingwith
and declaring the object explicitly makes it work.To Reproduce (in terms of terminal commands)
Expected Behavior
mypy would return no errors.
Actual Behavior
mypy returned errors.
Your Environment
--warn-return-any
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: