4 ms·
Here we have a problem: If the “subscription” part of the “patch” data-structure is set to “None” it is impossible to tell if this means: 1/ leave the “subscr
by gorgoiler 2y ago
Here we have a problem:
If the “subscription” part of the “patch” data-structure is set to “None” it is impossible to tell if this means:
1/ leave the “subscription” unchanged; or
2/ set the “subscription” to None.
—
You could solve this by requiring that a subscription is either a value or some other sentinel value meaning “not subscribed”:
from typing import Union
class T: pass
NotSubscribed = T()
Subscription = Union[int, T]
def f(s: Subscription): pass
f(44)
f(NotSubscribed)
f(None) # wrong
Is there a better way of doing this? (One that isn’t just “use Haskell” :)