python / python/mypy

Add a new option for `stubtest`: `--ensure-runtime-generic`

Offen
#19,032 0 Kommentare 1 Reaktion 1 zugewiesene Person Auf GitHub ansehen

@sobolevn arbeitet bereits daran.

Seit 05.5.2025.

feature topic-stubtest
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

In django-stubs we have a problem: some types that we declare generic are not generic in runtime.

We have a special package to monkeypatch runtime types to add __class_getitem__ to classes: https://github.com/typeddjango/django-stubs/blob/08cdfe576d62fc3a2dfc33197a3260cb0a0dc097/ext/django_stubs_ext/patch.py#L56

But, we cannot really catch this. We have a lot of report about some type being generic in stubs but not in runtime. And we have to add new entries to our list of patched types.

We would really love to see --ensure-runtime-generic option for stubtest which will check that types that are generic in stubs are also generic in runtime.

It should be switched off by default.

I can work on this if others are fine with the idea itself.

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.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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