Skip to content

Add a new option for stubtest: --ensure-runtime-generic #19032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sobolevn opened this issue May 5, 2025 · 0 comments
Open

Add a new option for stubtest: --ensure-runtime-generic #19032

sobolevn opened this issue May 5, 2025 · 0 comments

Comments

@sobolevn
Copy link
Member

sobolevn commented May 5, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant