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
fromtypingimportNewTypeA=NewType("A", int)
B=NewType("B", str)
deftest(x: A|B):
matchx:
caseA():
print("A")
caseB():
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.
Activity
erictraut commentedon Aug 12, 2025
This isn't really a type error, but pyright does provide similar checks, so I think this is a reasonable enhancement request.
Added check for the use of a `NewType` in a class pattern. This addre…
Added check for the use of a `NewType` in a class pattern. This addre…
erictraut commentedon Oct 1, 2025
This is addressed in 1.1.406