python / python/mypy

Get rid of fake TypeInfo's for TypedDicts

Offen
#8,620 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug priority-1-normal refactoring topic-typed-dict
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

We currently create fake TypeInfos to store TypedDicts. This used to cause various issues, in particular, currently the type of a TypedDict "class object" in runtime context is () -> SomeTypedDict, where the return type is an instance of the fake TypeInfo.

We can probably fix latter by just constructing a reasonable type, but a more global solution would be to get rid of the fake TypeInfo entirely. It is not needed for anything and just complicates things. We will need to put some symbol node in the symbol table, so we would need a new SymbolNode subclass (or reuse TypeAlias, so a TypedDict definition A = TypedDict('A' {'x': int, 'y': int}) will be very similar to A = Dict[str, int]).

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit nachzuverfolgen, wo TypedDict-Definitionen künstliche TypeInfos erzeugen und wie ihre Symbole in der Symboltabelle gespeichert werden. Prüfe eine neue SymbolNode-Unterklasse oder eine TypeAlias-Darstellung und verifiziere anschließend, dass TypedDicts keine künstlichen TypeInfos mehr benötigen und dass ihr Klassentyp als Objekt im Laufzeitkontext sinnvoll ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
compilers
Issue-Typ
Refactoring
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.