Fix CallbackData without default Optional - #1370
Merged
Merged
Conversation
✔️ Changelog found.Thank you for adding a description of the changes |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## dev-3.x #1370 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 369 369
Lines 9449 9455 +6
=========================================
+ Hits 9449 9455 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Olegt0rr
marked this pull request as ready for review
November 20, 2023 09:09
JrooTJunior
requested changes
Nov 20, 2023
This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable.
This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable.
JrooTJunior
approved these changes
Nov 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1368
Method
.is_required()returnsTrueonOptional[int]without default value, because it's still requires eitherintorNonevalue.On the other hand, when we parse a value from a zero-length string - it cannot be converted to
Noneor anint, so pyantic returns an error about it.The solution to this problem is to adapt the field type check to such a case.