Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django-stubs/db/models/fields/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class FloatField(Field[_ST, _GT]):
class DecimalField(Field[_ST, _GT]):
_pyi_private_set_type: str | float | decimal.Decimal | Combinable
_pyi_private_get_type: decimal.Decimal
_pyi_lookup_exact_type: str | decimal.Decimal
_pyi_lookup_exact_type: str | int | decimal.Decimal
# attributes
max_digits: int
decimal_places: int
Expand Down
23 changes: 23 additions & 0 deletions tests/typecheck/managers/querysets/test_filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@
class User(models.Model):
age = models.IntegerField()
# Regression test for #2831
- case: filter_with_decimal
main: |
from myapp.models import MyModel
from decimal import Decimal
MyModel.objects.filter(a=1)
MyModel.objects.filter(a="1.0")
MyModel.objects.filter(a=Decimal(1.0))
MyModel.objects.filter(a=1.0)
out: |
main:7: error: Incompatible type for lookup 'a': (got "float", expected "str | int | Decimal") [misc]
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from django.db import models
class MyModel(models.Model):
a = models.DecimalField()
- case: filter_with_multiple_fields
main: |
Expand Down
Loading