-
-
Notifications
You must be signed in to change notification settings - Fork 378
Allow pickling Cancelled
#3250
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
Allow pickling Cancelled
#3250
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3250 +/- ##
================================================
Coverage 100.00000% 100.00000%
================================================
Files 124 124
Lines 18848 19340 +492
Branches 1277 1318 +41
================================================
+ Hits 18848 19340 +492
🚀 New features to boost your workflow:
|
|
we could instead add |
I was thinking that too (we'd need to add it in |
|
Alright generally applying The main point is the number of |
src/trio/_util.py
Outdated
| def __new__(cls, name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: object) -> type: # type: ignore[explicit-any] | ||
| old_reduce = namespace.get("__reduce__") | ||
|
|
||
| def __reduce__(self: object) -> Any: # type: ignore[explicit-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.
In this case, wouldn't self be an instance of NoPublicConstructor? If so, that would probably alleviate the attr-defined error on line 335
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.
No, Cancelled itself is an instance of NoPublicConstructor, (well not exactly cause we hand that off to type in __new__ but that's the idea) not instances of Cancelled. Metaclasses are weird!
jakkdl
left a comment
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.
just a couple small things, otherwise looks as good as it could given the messiness of metaclasses :)
Co-authored-by: jakkdl <h6+github@pm.me>
jakkdl
left a comment
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.
okay I looked a bit more thorough now and found some small things :)
|
Turns out I underestimated pickling. It's more complicated than I expected and I don't think there's a way to generalize support to any class. I was operating in a world where |
It's too much complexity to do it correctly.
jakkdl
left a comment
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.
sorry for the detour ^^; Back to nice and simple
Fixes #3248