-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
multiple_of
failing on some negative floats
#9871
Comments
Huh, this is definitely a bug. Thanks for reporting this! Likely an issue due to undesired rounding. A PR with a fix is more than welcome! |
Hi, I've been investigating this today, seems that using from typing import Annotated
from pydantic import TypeAdapter, Field
from decimal import Decimal
for i in range(-10, 10):
x = i / 100
try:
TypeAdapter(Annotated[Decimal, Field(multiple_of=0.01)]).validate_python(x)
print(f" OK: {x}")
except:
print(f"FAIL: {x}") Results in:
This should be fixed at |
@sydney-runkle |
Hi @K-dash, Just wanted to point out that IMO - to maintain coherence with the existing setting - you might want to add the same test parametrizations of |
Hi @AlessandroMiola |
Initial Checks
Description
Why does it work on
x
but fails on-x
? Is this intended behavior?Example Code
prints:
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: