Skip to content

Commit

Permalink
Add DecimalField(normalize_output=) from DRF master (#294)
Browse files Browse the repository at this point in the history
This isn't in any DRF release yet, but fixes typecheck in our CI.

Upstream PR: encode/django-rest-framework#6514
  • Loading branch information
intgr committed Nov 16, 2022
1 parent 95b370f commit 11ecec9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import datetime
import uuid
from collections import OrderedDict
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, Sequence
from decimal import Decimal
from enum import Enum
from json import JSONDecoder, JSONEncoder
from collections.abc import Callable, Generator, Iterable, Mapping, MutableMapping, Sequence
from re import Pattern
from typing import Any, Generic, NoReturn, Protocol, TypeVar
from _typeshed import Self

from _typeshed import Self
from django.core.files.base import File
from django.db import models
from django.forms import ImageField as DjangoImageField # noqa: F401
from typing_extensions import Final, TypeAlias

from rest_framework.serializers import BaseSerializer
from rest_framework.validators import Validator
from typing_extensions import Final, TypeAlias

class _Empty(Enum):
sentinel = 0 # noqa: Y015
Expand Down Expand Up @@ -340,6 +339,7 @@ class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
min_value: Decimal | int | float = ...,
localize: bool = ...,
rounding: str | None = ...,
normalize_output: bool = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
Expand Down
4 changes: 2 additions & 2 deletions tests/typecheck/test_fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from django.db import models
from rest_framework.fields import DecimalField, IPAddressField, SlugField, RegexField, ModelField, SerializerMethodField, ChoiceField
DecimalField(1, 1, False, 1, 1, False, None)
DecimalField(1, 1, False, 1, 1, False, None, True) # E: Too many positional arguments for "DecimalField"
DecimalField(1, 1, False, 1, 1, False, None, True)
DecimalField(1, 1, False, 1, 1, False, None, True, True) # E: Too many positional arguments for "DecimalField"
IPAddressField('both')
IPAddressField('both', True) # E: Too many positional arguments for "IPAddressField"
Expand Down

0 comments on commit 11ecec9

Please sign in to comment.