Skip to content

[3.15] Add DecimalField normalize_output argument #584

New issue

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

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
min_value: Decimal | int | float | None
localize: bool
rounding: str | None
normalize_output: bool
max_whole_digits: int | None
def __init__(
self,
Expand All @@ -342,6 +343,7 @@ class DecimalField(Field[Decimal, int | float | str | Decimal, str, Any]):
min_value: Decimal | int | float | None = None,
localize: bool = ...,
rounding: str | None = None,
normalize_output: bool = ...,
*,
read_only: bool = ...,
write_only: bool = ...,
Expand Down
2 changes: 0 additions & 2 deletions scripts/stubtest/allowlist_todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,12 @@ rest_framework.views.GenericView

# Added in 3.15:
rest_framework.authtoken.migrations.0004_alter_tokenproxy_options
rest_framework.fields.DecimalField.__init__
rest_framework.fields.Field.__class_getitem__
rest_framework.filters.search_smart_split
rest_framework.generics.GenericAPIView.__class_getitem__
rest_framework.request.Request.__class_getitem__
rest_framework.response.Response.__class_getitem__
rest_framework.routers.BaseRouter.is_already_registered
rest_framework.serializers.DecimalField.__init__
rest_framework.serializers.Field.__class_getitem__
rest_framework.serializers.LIST_SERIALIZER_KWARGS_REMOVE
rest_framework.serializers.ListSerializer.run_child_validation
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 @@ -13,8 +13,8 @@
from django.db import models
from rest_framework.fields import DecimalField, IPAddressField, SlugField, RegexField, ModelField, SerializerMethodField, ChoiceField, DateTimeField, DateField, TimeField

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, False)
DecimalField(1, 1, False, 1, 1, False, None, False, True) # E: Too many positional arguments for "DecimalField"

IPAddressField('both')
IPAddressField('both', True) # E: Too many positional arguments for "IPAddressField"
Expand Down