-
Notifications
You must be signed in to change notification settings - Fork 91
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
__aexit__
should return bool | None
, not None
#193
Comments
Forwarding There is only one place where we suppress exceptions and that But method signatures, especially those which are part of public API, should be correct anyway, so I will fix them. |
Tried to fix signatures but then MyPy requires you to add return statements where they're not needed. So I will leave it as it is right now if there is no real issues. Feel free to update this issue with a reproducible code example which shows your issue. |
I am getting typing errors, I guess it is because the type I'm calling |
According to Python docs:
When writing generic code, one needs to take into account that
__aexit__
could returnTrue
too, so even when in the particular case of grpclib it might never returnNone
, the return type hint should beOptional[bool]
, otherwise when trying to store the return value to properly forward it when writing a wrapper,mypy
will complain about getting a value which can only beNone
for the case of grpclib.Having a quick look at the code, I'm not even sure if grpclib isn't actually supressing some exception in some
__aexit__
(for example inStream
), so there might be even a bug lurking out there. Since I'm not familiar with the code it will take me a non trivial amount of time to find out.The text was updated successfully, but these errors were encountered: