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
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.
The text was updated successfully, but these errors were encountered:
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.
The first overload of
pow
currently looks like this:When the argument types are not known, Pyright and Pyre use the first overload -- the
NoReturn
overload.Here's an example from microsoft/pylance-release#3214:
@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.The text was updated successfully, but these errors were encountered: