python / python/typing

Discrepancy between spec and tests on indexing TypedDicts with non-literal variables

Offen
#2,053 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

topic: typing spec
Vorherrschende Sprache
Python
Sterne
1.8k
Forks
302
Ø Merge
23 Std.
Gemergte PRs (30 T.)
8

Beschreibung

Splitting issue from PR https://github.com/python/typing/pull/1978

Spec says that it should be generally rejected (ref)

A key that is not a literal should generally be rejected, since its value is unknown during type checking, and thus can cause some of the above violations.

But currently conformance tests do not reflect it.

https://github.com/python/typing/blob/2d88da2a407b556f5b52b4c6ad1bd659873bb9ac/conformance/tests/typeddicts_operations.py#L34-L38

So in theory to resolve this, either strictness should be reflected in conformance tests or spec should be amended allowing optional enforcement.

Related discussion - https://discuss.python.org/t/indexing-typeddict-with-a-non-literal-variable/88929

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

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

Beginnen Sie mit dem Abschnitt zur TypedDict operations spec und conformance/tests/typeddicts_operations.py um die Zeilen 34-38 herum, lesen Sie dann PR 1978 und die verknüpfte Diskussion. Ermitteln Sie, ob die Conformance-Tests die Indizierung mit Nicht-Literalen ablehnen sollten oder ob die Spezifikation eine optionale Durchsetzung erlauben sollte. Als erledigt gilt die Aufgabe, wenn die Spezifikation und die Conformance-Tests das vereinbarte Verhalten konsistent beschreiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
documentation, testing
Issue-Typ
Dokumentation
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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