Open mvandenburgh opened 2 years ago
Unfortunately, this won't work well for any settings that have a value of None
, {}
or []
, i.e. settings where their type can't be inferred from their runtime value. For those, you'll get errors like Invalid index type "str" for "dict"; expected type "_KT"
. A better approach would be to make a mypy plugin that can find the setting definitions on the Configuration
subclass that you're using and take the type hints from there. I've written such a plugin and it works well, but haven't had time to open-source it yet. If anyone wants that plugin, let me know here and I'll spend some time open-sourcing it.
Fixes #267. Related issue in the
django-stubs
repo - https://github.com/typeddjango/django-stubs/issues/417I've also added a section to the docs describing how to use this.