-
-
Notifications
You must be signed in to change notification settings - Fork 15
remove reference to value/error when unwrapping outcome #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 |
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.
try: | ||
return f'Error({self.error!r})' | ||
except AttributeError: | ||
return 'Error(<DEAD>)' |
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.
Can this be Error(<AlreadyUsed>)
?
def _unwrap_error(self) -> BaseException: | ||
try: | ||
v = self.error | ||
except AttributeError: |
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.
Can we use descriptors to transmute any late access to self.error
or self.value
directly to AlreadyUsedError
?
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.
Maybe __getattr__
?
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.
Make them private attributes, add a property?
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 |
No description provided.