Skip to content

Too many cycle iterations for infinitely wrapped instance of generic class #1383

@sharkdp

Description

@sharkdp

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)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfatala fatal error (panic or crash)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions