-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
astral-sh/ruff
#21999Description
Summary
In this example, ty reveals a type of Never for other in baz, but still reports an invalid-return-type error.
from typing import Self, final, reveal_type
@final
class Foo:
def bar(self, other: Foo) -> bool:
if isinstance(other, Foo): return True
def baz(self, other: Self) -> bool:
# ^^^^ Function can implicitly return `None`, which is not assignable to return type `bool` (invalid-return-type)
if isinstance(other, Foo): return True
reveal_type(other) # revealed: Neverbasedpyright andmypyreport no errors on this code snippet.
Version
ty ruff/0.14.9+38 (4e1cf5747 2025-12-15)
Reactions are currently unavailable