-
Notifications
You must be signed in to change notification settings - Fork 171
Open
astral-sh/ruff
#22233Labels
bugSomething isn't workingSomething isn't workingcallsIssues relating to call-signature checking and diagnosticsIssues relating to call-signature checking and diagnostics
Milestone
Description
Summary
This code passes Ty without any warnings. But when run it will fail half the time.
from __future__ import annotations
from random import randint
from typing import TYPE_CHECKING
class A:
def __new__(cls) -> int | A:
if randint(0, 1):
return object.__new__(cls)
else:
return randint(0, 100)
def f(x: A) -> None:
assert isinstance(x, A)
a = A()
f(a)f expects value of type A. But A.__new__ might return int. So constructor of A should not be assumed to always return A. Ty should flag call f(a).
Version
ty 0.0.0-alpha.7
bobbyrenwick and goodspark
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcallsIssues relating to call-signature checking and diagnosticsIssues relating to call-signature checking and diagnostics