outcome icon indicating copy to clipboard operation
outcome copied to clipboard

remove reference to value/error when unwrapping outcome

Open graingert opened this issue 8 months ago • 3 comments

graingert avatar Mar 22 '25 10:03 graingert

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.

TeamSpen210 avatar Mar 22 '25 16:03 TeamSpen210

could just call it InvalidatingOutcome, InvalidatingError and InvalidatingValue

graingert avatar Mar 22 '25 16:03 graingert

A parallel class hierarchy seems problematic, they'd be incompatible with the current ones. More thinking like unwrap_and_clear(), that's all we need.

TeamSpen210 avatar Mar 22 '25 17:03 TeamSpen210

Would using a weak reference not be acceptable?

CoolCat467 avatar Mar 31 '25 21:03 CoolCat467

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

graingert avatar Mar 31 '25 21:03 graingert

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 AlreadyUsedError over AttributeError.

The way I've always used outcome is to only .unwrap() or .send(), so I would be fine with an outcome 2.0 that doesn't have the attributes, but I know Trio does use them.

RazerM avatar Apr 04 '25 17:04 RazerM