typeddjango / django-stubs

PEP-484 stubs for Django
MIT License
1.6k stars 446 forks source link

Allow to work with django-configurations #1709

Open kaldown opened 1 year ago

kaldown commented 1 year ago

Following documentation do not solve the issue of django-stubs working with django-configurations

[tool.mypy]
mypy_path = "./src"
plugins = ["mypy_django_plugin.main"]

[tool.django-stubs]
django_settings_module = "myproj.settings"
strict_settings = false

Returns an Error:

Error constructing plugin instance of NewSemanalDjangoPlugin
...
raise ImproperlyConfigured(install_failure)
django.core.exceptions.ImproperlyConfigured: django-configurations settings importer wasn't correctly installed. Please use one of the starter functions to install it as mentioned in the docs: https://django-configurations.readthedocs.io/

Note:

Whilst commenting usage of django-stubs in [tool.mypy] directive of pyproject.toml leading to expected issue of mypy not being able to catch django types from models.py (for example).

Note 2:

As I see this PR https://github.com/typeddjango/django-stubs/pull/180 is still open. Would it be better to remove django-configurations entry from README.md since it could cause confusion?

System information

sobolevn commented 1 year ago

@kaldown do you want to experiment with code / docs changes to support django-configurations? :)

kaldown commented 1 year ago

@kaldown Sure thing, I would glad to. I need you to look at https://github.com/typeddjango/django-stubs/pull/180 and tell me if this is not a convenient solution or if there are any caveats you want to be addressed.

I have to admit I never-ever used typing in python. Started with my pet project I gave it a shot, and straight away drove into the "issue". In order to not be overwhelmed by the new tool, and knowing you are one of the main contributors to django-stubs and related projects - I am asking your advice, it would really help me to achieve better results.

If your advice would be to only change documentation or adjust related PR - I'm fine with this too. Thank you.

kaldown commented 1 year ago

Hey @sobolevn , what do you think about my request?

sobolevn commented 1 year ago

Sorry, I don't have time right now to dig into this :(