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
Django model Field value as a part of a union results in unexpected behavior. Please find the following example:
from typing import Union from uuid import UUID from django.db import models class User(models.Model): uuid = models.UUIDField() class AnonymousUser: uuid: UUID def example(value: UUID) -> None: ... user_only: User = User() anonymous_only: AnonymousUser = AnonymousUser() union_value: Union[AnonymousUser, User] = User() example(user_only.uuid) example(anonymous_only.uuid) example(union_value.uuid)
It causes the following error
test.py:25: error: Argument 1 to "example" has incompatible type "Union[UUID, UUIDField[Union[str, UUID], UUID]]"; expected "UUID"
No error should be raised.
python
django
mypy
django-stubs
The text was updated successfully, but these errors were encountered:
This is an upstream problem for classes with descriptors, ref: python/mypy#5570 (comment)
I'm gonna close this in favour of the mypy issue.
Sorry, something went wrong.
No branches or pull requests
Bug report
What's wrong
Django model Field value as a part of a union results in unexpected behavior. Please find the following example:
It causes the following error
How is that should be
No error should be raised.
System information
python
version: 3.8.9django
version: 3.2.6mypy
version: 0.910django-stubs
version: 1.8.0The text was updated successfully, but these errors were encountered: