lundi 14 septembre 2020

get_type_hints raise NamError with local class

I am using the python function typing.get_type_hints(). Unfortunately this function raise an error when I pass a local class that contains a reference to itself.

Is this a bug or am I doing something wrong ?
If indeed it's a bug where should I report it ?

from typing import *

class Tata:
    parent: "Tata"

def example():
    class Toto:
        parent: "Toto"

    print(get_type_hints(Tata))
    print(get_type_hints(Toto))  # Raise NameError: name 'Toto' is not defined





Aucun commentaire:

Enregistrer un commentaire