This is a heavily modified MRE for the ecosystem panic observed on "bokeh" in astral-sh/ruff#20922. As with most of the previous bug reports sprawling from those PRs, this one is also reproducible on main
, if we simply add a self: Self
annotation. The reason why this leads to divergent behavior is probably that the generic context of Value
keeps track of the recursive nesting (Value[Value[Value[...[Value[T]]]]]
):
from typing import Self
class Value[T]:
def __init__(self, value: T) -> None: ...
class C:
def f(self: Self) -> None:
self.value = Value(self.value)