Right now create_instance
can take any **kwargs
.
But, mypy has no way of actually checking that id=1, address__id=2
are valid keywords for this call.
It can be caught when executed, sure. But typechecking is much faster than writing code + writing tests + running them.
In Django we have a similar pattern of passing keywords like this to filters. Like: User.objects.filter(id=1, settings__profile="public")
. For this we use a custom mypy plugin: https://github.com/typeddjango/django-stubs/blob/c9c729073417d0936cb944ab8585ad236ab30321/mypy_django_plugin/transformers/orm_lookups.py#L10
What it does?
__
ones also exist on the nested model**custom_data
unpackingtype: ignore[custom-code]
custom-code
is disabled in mypy checksPlus, in the future more goodies can be added, included DI proper checking, URL params, etc.
It will require its own set of tests via typing.assert_type
and maintaince time. Mypy sometimes break plugin-facing APIs.
I can write this plugin if others are interested :)
No response
No response
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too