Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created December 21, 2024 00:48
Show Gist options
  • Save mypy-play/c42e62c91d23507603844e6e4abd8382 to your computer and use it in GitHub Desktop.
Save mypy-play/c42e62c91d23507603844e6e4abd8382 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Union, Never
def check(x: int) -> Union[Never, str]:
try:
assert x == 2, "Expected 2"
return "Sat"
except AssertionError as msg:
print(msg)
@dibrinsofor
Copy link

Mypy returns with

main.py:3: error: Missing return statement  [return]
Found 1 error in 1 file (checked 1 source file)

Does Never work other than specified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment