-
Notifications
You must be signed in to change notification settings - Fork 287
Add support for mypy plugins to enable django-stubs testing in typeshed library #1990
huynguyengl99
started this conversation in
General
-
We can support Django type checking via mypy's django-stubs plugin. The required mypy.ini configuration is simply:
[mypy]
plugins = mypy_django_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = scripts.tests_settings
With a minimal tests_settings.py file:
SECRET_KEY = "1" INSTALLED_APPS = ( "django.contrib.contenttypes", "django.contrib.sites", "django.contrib.sessions", "django.contrib.messages", "django.contrib.admin.apps.SimpleAdminConfig", "django.contrib.staticfiles", "django.contrib.auth", "channels", )
I propose we extend our typing tools to support mypy plugins by adding the "plugins" field to the KNOWN_METADATA_TOOL_FIELDS dictionary:
KNOWN_METADATA_TOOL_FIELDS: Final = { "stubtest": { "skip", "apt_dependencies", "brew_dependencies", "choco_dependencies", "extras", "ignore_missing_stub", "platforms", "stubtest_requirements", }, "mypy": { "plugins", } }
This would allow package maintainers to specify in their METADATA.toml:
[tool.mypy] plugins = "mypy_django_plugin.main" [tool.mypy.plugins.django-stubs] django_settings_module = "scripts.tests_settings"
This enhancement would enable proper stubtest functionality for Django-based stubs libraries. What do you think about this idea?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
I will be happy to help from django-stubs side :)
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment