-
-
Notifications
You must be signed in to change notification settings - Fork 15
remove reference to value/error when unwrapping outcome, and add .peek() method
#45
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
base: main
Are you sure you want to change the base?
Conversation
7c22bcb to
20c75bf
Compare
20c75bf to
08b08df
Compare
49cd098 to
4d40df0
Compare
|
This might need to be a new method for backwards compatibility, since the attributes are public, users would be able to still read them after unwrapping. Unless we're fine with that breaking change. |
|
could just call it InvalidatingOutcome, InvalidatingError and InvalidatingValue |
|
A parallel class hierarchy seems problematic, they'd be incompatible with the current ones. More thinking like |
|
Would using a weak reference not be acceptable? |
I think that would be more complicated and it would be odd that unwrapped values are sometimes there sometimes not and not everything can be weakref'd |
richardsheridan
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.
I'm +1 on "just delete the attribute on unwrap". It's understandable and minimal and the only issue is backwards compatibility, so I'd say slap a unwrap_and_clear() method on version 1.4.0 and make a 2.0.0 release for the cleaner implementation to free more users from refcycles.
|
I'm -1 on deleting public attributes during unwrap. I don't like that accessing an attribute/property may raise, but if we go that route then I'd much prefer The way I've always used outcome is to only |
|
I was off sick and didn't have time to focus on this PR, I'd like to pick it back up again |
856bb3c to
6a1174b
Compare
6a1174b to
47e6abd
Compare
add types e.error unwraps
47e6abd to
2606efb
Compare
62a114b to
fdbd48d
Compare
|
I do wonder, since this is a breaking change, maybe it'd be better to make it entirely breaking - change the properties to |
CoolCat467
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.
I don't see any immediate issues. Would raise the possibility of sharing peek and return, return/unwrap just being peek and then unset, but as is is still fine.
|
ok let's add peek |
.peek()
.peek().peek() method
Fixes #47
currently unwraping exceptions leaves a refcycle that keeps the entire traceback and any locals alive. This PR resolves that by clearing the error field when the Error is unwrapped.
For the previous behaviour of Value (eg in trio) if you receive a large bytes object in a Value that bytes object stays alive long after it's needed. This PR resolves that by clearing the value field when the Value is unwrapped.
this is a breaking change and should probably be released with a major version bump, eg outcome==2.0.0