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
class WithX:
x: int
@final
class Other:
pass
def foo(obj: WithX | Other):
if hasattr(obj, "x"):
# ➖ pyrefly | revealed type: Other | WithX
# ✅ ty. | Revealed type: `WithX`
# ➖ mypy. | Revealed type is "Union[__main__.WithX, __main__.Other]"
# ➖ pyright | Type of "obj" is "WithX | Other"
reveal_type(obj)
Q. Is ty sound for property methods? Go back to the static python example.
class MyClass:
...
class MySubclass(MyClass):
...
def bar(obj: MyClass):
if not isinstance(obj, MySubclass):
# ➖ pyrefly | revealed type: MyClass
# ✅ ty. | Revealed type: `MyClass & ~MySubclass`
# ➖ mypy. | Revealed type is "__main__.MyClass"
# ➖ pyright | Type of "obj" is "MyClass"
reveal_type(obj)
Q. How set-theoretic are ty types? Is A & -B equal to -B & A ?
Q. Ty aspires to the gradual guarantee. I bet there are counterexamples, but then again Carl Meyer is involved and he knows all about why Static Python broke the gradual guarantees!
The text was updated successfully, but these errors were encountered:
There are 2 fast new typecheckers coming to Python:
Quick comparison:
Notes:
Q. How set-theoretic are ty types? Is
A & -B
equal to-B & A
?Q. Ty aspires to the gradual guarantee. I bet there are counterexamples, but then again Carl Meyer is involved and he knows all about why Static Python broke the gradual guarantees!
The text was updated successfully, but these errors were encountered: