from typing import NewType
A = NewType("A", int)
B = NewType("B", str)
def test(x: A | B):
match x:
case A():
print("A")
case B():
print("B")
test(A(123))
"""
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
test(A(123))
~~~~^^^^^^^^
File "<stdin>", line 3, in test
case A():
~^^
TypeError: called match pattern must be a class
"""
This code causes an exception at runtime, but pyright doesn't produce any errors.
Pyright Playground
Related: #6828
This code causes an exception at runtime, but pyright doesn't produce any errors.
Pyright Playground
Related: #6828