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(base_quantity): Removed string return from serialization of pint quantity. #28

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

pesap
Copy link
Collaborator

@pesap pesap commented Jun 2, 2024

List of changes:

  • Removed str(input_value.magnitude) to return a proper number instead of a string when calling .model_dump()
  • Added a specific serialization option when calling .model_dump(mode="json") or .model_dump_json() to return a string version of the field. This is only import for pint quantities, such that it returns something like 10 kV that is easily deserialized with pint,
  • Added better type check for instances of the BaseQuantity used on the pydantic model,
  • Relaxed the schema serialization since pint will handle most of it,
  • Added better typehint for pydantic classmethods

quantity.

List of changes:
- Removed str(input_value.magnitude) to return a proper number instead
  of a string when calling `.model_dump()`
- Added a specific serialization option when calling
  `.model_dump(mode="json")` or `.model_dump_json()` to return a string
  version of the field. This is only import for pint quantities, such
  that it returns something like `10 kV` that is easily deserialized
  with pint,
- Added better type check for instances of the BaseQuantity used on the
  pydantic model,
- Relaxed the schema serialization since pint will handle most of it,
- Added better typehint for pydantic classmethods
@pesap pesap added the chore label Jun 2, 2024
@pesap pesap requested a review from daniel-thom June 2, 2024 00:53
@pesap pesap self-assigned this Jun 2, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.02%. Comparing base (25a110a) to head (26521e1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   95.88%   96.02%   +0.14%     
==========================================
  Files          25       25              
  Lines        2165     2166       +1     
==========================================
+ Hits         2076     2080       +4     
+ Misses         89       86       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pesap
Copy link
Collaborator Author

pesap commented Jun 5, 2024

@daniel-thom This is ready to re-review.

@pesap pesap merged commit bd1ab2e into main Jun 5, 2024
6 checks passed
@pesap pesap deleted the ps/serialization branch June 5, 2024 19:05
github-actions bot pushed a commit that referenced this pull request Jun 5, 2024
…quantity. (#28)

List of changes:
- Removed str(input_value.magnitude) to return a proper number instead
  of a string when calling `.model_dump()`
- Added a specific serialization option when calling
  `.model_dump(mode="json")` or `.model_dump_json()` to return a string
  version of the field. This is only import for pint quantities, such
  that it returns something like `10 kV` that is easily deserialized
  with pint,
- Added better type check for instances of the BaseQuantity used on the
  pydantic model,
- Relaxed the schema serialization since pint will handle most of it,
- Added better typehint for pydantic classmethods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants