Skip to content

Commit 11ecec9

Browse files
authored
Add DecimalField(normalize_output=) from DRF master (#294)
This isn't in any DRF release yet, but fixes typecheck in our CI. Upstream PR: encode/django-rest-framework#6514
1 parent 95b370f commit 11ecec9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

rest_framework-stubs/fields.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import datetime
22
import uuid
33
from collections import OrderedDict
4+
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, Sequence
45
from decimal import Decimal
56
from enum import Enum
67
from json import JSONDecoder, JSONEncoder
7-
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, Sequence
88
from re import Pattern
99
from typing import Any, Generic, NoReturn, Protocol, TypeVar
10-
from _typeshed import Self
1110

11+
from _typeshed import Self
1212
from django.core.files.base import File
1313
from django.db import models
1414
from django.forms import ImageField as DjangoImageField # noqa: F401
15-
from typing_extensions import Final, TypeAlias
16-
1715
from rest_framework.serializers import BaseSerializer
1816
from rest_framework.validators import Validator
17+
from typing_extensions import Final, TypeAlias
1918

2019
class _Empty(Enum):
2120
sentinel = 0 # noqa: Y015
@@ -340,6 +339,7 @@ class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
340339
min_value: Decimal | int | float = ...,
341340
localize: bool = ...,
342341
rounding: str | None = ...,
342+
normalize_output: bool = ...,
343343
*,
344344
read_only: bool = ...,
345345
write_only: bool = ...,

tests/typecheck/test_fields.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from django.db import models
1313
from rest_framework.fields import DecimalField, IPAddressField, SlugField, RegexField, ModelField, SerializerMethodField, ChoiceField
1414
15-
DecimalField(1, 1, False, 1, 1, False, None)
16-
DecimalField(1, 1, False, 1, 1, False, None, True) # E: Too many positional arguments for "DecimalField"
15+
DecimalField(1, 1, False, 1, 1, False, None, True)
16+
DecimalField(1, 1, False, 1, 1, False, None, True, True) # E: Too many positional arguments for "DecimalField"
1717
1818
IPAddressField('both')
1919
IPAddressField('both', True) # E: Too many positional arguments for "IPAddressField"

0 commit comments

Comments
 (0)