-
-
Notifications
You must be signed in to change notification settings - Fork 18
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 frozenset deserialization. #342
Conversation
constraints: Tuple[Constraint, ...] | ||
value_method: DeserializationMethod | ||
|
||
def deserialize(self, data: Any) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to rewrite a complete method for frozenset
; ListMethod
should be reused, as it's already the case for variadic tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, I think super()
was not supported (in Cython generation) when I wrote VariadicTupleMethod
, but this one, as well as FrozenSetMethod
should simply inherit ListMethod
and use for example return tuple(super().deserialize(data))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After inspection, it is not straightforward, since VariadicTupleMethod
could inherit from ListCheckOnlyMethod
or ListMethod
.
It looks like all collection deserialization methods could benefit from only checking their item values, so I'd say that it would be better to do some refactoring here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it was not a question of super()
support … I was too quick in my response. So composition should be used the same way VariadicTupleMethod
does.
Codecov Report
@@ Coverage Diff @@
## master #342 +/- ##
==========================================
- Coverage 86.13% 86.11% -0.03%
==========================================
Files 67 67
Lines 5879 5898 +19
Branches 1218 1222 +4
==========================================
+ Hits 5064 5079 +15
- Misses 596 599 +3
- Partials 219 220 +1
Continue to review full report at Codecov.
|
@pchanial |
42bb0ff
to
90c4687
Compare
90c4687
to
2d54825
Compare
I had made the change before your last comment, so I just pushed it. I have started looking at ways to refactor this part but the tests fail with cython. I'll make another PR so we can discuss it. |
Closes #341
Note that there is another unit test failure : the deserialization of BigInt is not a BigInt instance. For this test case, I've explicitly disabled the new type check since it is another issue.