[Python] mypy complains for static variable

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    mypy (v.1.15.0) complains with the following message Access to generic instance variables via class is ambiguous for the following code:

    from typing import Self

    class A:
    B: Self

    A.B = A()


    If I remove B: Self, then is says "type[A]" has no attribute "B".

    How make mypy happy? You can play with this here: mypy playground

    Continue reading...

Compartilhe esta Página