We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I get a mypy error when I use a callable on a ForeignKey.limit_choices_to argument:
ForeignKey.limit_choices_to
error: Argument "limit_choices_to" to "ForeignKey" has incompatible type "Callable[[], dict[str, set[Any]]]"; expected "Q | dict[str, Any] | _ChoicesCallable | None" [arg-type]
My code looks like this:
def limit_to_procedures() -> dict[str, set[Any]]: return {"pk__in": {content_type.pk for content_type in ContentType.objects.get_for_models(*AbstractModel.__subclasses__()).values()}} def Foo(Model): content_type = ForeignKey(ContentType, limit_choices_to=limit_to_procedures, on_delete=CASCADE)
No error should be thrown.
python
django
mypy
django-stubs
django-stubs-ext
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug report
What's wrong
I get a mypy error when I use a callable on a
ForeignKey.limit_choices_to
argument:My code looks like this:
How is that should be
No error should be thrown.
System information
python
version: 3.12.7django
version: 5.1.1mypy
version: 1.11.2django-stubs
version: 5.1.0django-stubs-ext
version: 5.1.0The text was updated successfully, but these errors were encountered: