You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
powNoReturn overload is used by Pyright and Pyre when argument types are not known #8566
defRSAcompute(message, exponent, pubkey):
data=pow(message, exponent, pubkey)
# The rest of the function is marked as unreachable# because Pyright/Pylance see pow's return type as NoReturntoto=42returndatares=RSAcompute(12, 34, 56)
print("Similarly this line is considered unreachable")
@AlexWaygood, it looks like you added the NoReturn overload here. Does it actually help users? I'm wondering if it could be removed, or at least moved down in the overload ordering so Pyright and Pyre would behave better in this situation.
I think we should remove it. Returning NoReturn isn't a good fit for cases where the code throws an error the user probably isn't expecting, because it can easily lead to type checkers silently skipping the code. Ideally we'd be able to use something like TypingError from python/typing#1043. Until we have that, I think it's better to accept that we can't handle cases like this in the stub.
Reacted by Shantanu, Alex Waygood and Erik De Bonte
Activity
JelleZijlstra commentedon Aug 19, 2022
I think we should remove it. Returning
NoReturnisn't a good fit for cases where the code throws an error the user probably isn't expecting, because it can easily lead to type checkers silently skipping the code. Ideally we'd be able to use something like TypingError from python/typing#1043. Until we have that, I think it's better to accept that we can't handle cases like this in the stub.AlexWaygood commentedon Aug 19, 2022
Sure, let's get rid of it and add a TODO comment. Thanks for raising the issue @debonte.