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
As we increase type coverage it would be great to add something like the following to functions that should handle all types, effectively using mypy to alert when pattern matching isn't exhaustive. This will help catch issues earlier on when large changes are made e.g. to support a new solidity feature.
from typing import NoReturn
def assert_never(x: NoReturn) -> NoReturn:
assert False, "Unhandled type: {}".format(type(x).__name__)
IntOrStr = int | str
def handle(x: IntOrStr) -> None:
if isinstance(x, str):
print(f"Handled {x}")
else:
assert_never(x) # Error: "int" is incompatible with "NoReturn"
As we increase type coverage it would be great to add something like the following to functions that should handle all types, effectively using mypy to alert when pattern matching isn't exhaustive. This will help catch issues earlier on when large changes are made e.g. to support a new solidity feature.
microsoft/pyright#2569
The text was updated successfully, but these errors were encountered: