8000 Remove coercion of decimal constraints by Viicos · Pull Request #11772 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
6 changes: 1 addition & 5 deletions pydantic/_internal/_known_annotated_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections import defaultdict
from collections.abc import Iterable
from copy import copy
from decimal import Decimal
from functools import lru_cache, partial
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -220,10 +219,7 @@ def apply_known_metadata(annotation: Any, schema: CoreSchema) -> CoreSchema | No
if constraint == 'union_mode' and schema_type == 'union':
schema['mode'] = value # type: ignore # schema is UnionSchema
else:
if schema_type == 'decimal' and constraint in {'multiple_of', 'le', 'ge', 'lt', 'gt'}:
schema[constraint] = Decimal(value)
else:
schema[constraint] = value
schema[constraint] = value
continue

# else, apply a function after validator to the schema to enforce the corresponding constraint
Expand Down
Loading
0