Skip to content
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

Fix float validation using decimal.Decimal #1073

Merged
merged 2 commits into from
Jan 31, 2023

Conversation

jsenecal
Copy link
Contributor

@jsenecal jsenecal commented Jan 31, 2023

  • Introduce the usage of decimal.Decimal in order to catch inconsistencies with operations against floats in Python
  • Created DecimalSafeLoader to deserialize YAML floats as decimal.Decimal
  • Added file handler for RefResolver in order to also cast decimal.Decimal to floats loaded through a $ref.

Closes #1068

@jsenecal jsenecal marked this pull request as draft January 31, 2023 04:41
@jsenecal jsenecal marked this pull request as ready for review January 31, 2023 04:52
@danner26
Copy link
Member

Just ran some tests against this PR, looks like it solves the issues along with the 10.11 pesky one we were fiddling with
Everything looks good to me, are we ready to merge this to master or is there anything else you need to do? @jsenecal

@jsenecal
Copy link
Contributor Author

Just ran some tests against this PR, looks like it solves the issues along with the 10.11 pesky one we were fiddling with Everything looks good to me, are we ready to merge this to master or is there anything else you need to do? @jsenecal

All good! This was fun to reverse-engineer!

@danner26 danner26 merged commit 1a4447a into netbox-community:master Jan 31, 2023
@jsenecal jsenecal deleted the 1068-fix-float-validation branch January 31, 2023 21:22
mjpereira602 pushed a commit to mjpereira602/devicetype-library that referenced this pull request Feb 22, 2023
* Fix float validation using decimal.Decimal

* Force string repr of the float when loading yaml

---------

Co-authored-by: Jonathan Senecal <[email protected]>
mjpereira602 pushed a commit to mjpereira602/devicetype-library that referenced this pull request Mar 1, 2023
* Fix float validation using decimal.Decimal

* Force string repr of the float when loading yaml

---------

Co-authored-by: Jonathan Senecal <[email protected]>
etherwrangler pushed a commit to etherwrangler/devicetype-library that referenced this pull request Jul 16, 2023
* Fix float validation using decimal.Decimal

* Force string repr of the float when loading yaml

---------

Co-authored-by: Jonathan Senecal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weight Validation
2 participants