3030# ==============================================================================
3131class Value (Generic [T ]):
3232 # These overloads are necessary so that the following hold:
33- # - Value() is marked by the type checker as an error. It is also a run-time error.
34- # - Value(MISSING) is marked by the type checker as an error, because the type T
35- # is unknown. (It is not a run-time error.)
36- # - Value[int](MISSING) works.
33+ # - Value() is marked by the type checker as an error, because the type T is
34+ # unknown. (It is not a run-time error.)
35+ # - Value[int]() works.
3736 # - Value[int](1) works.
3837 # - Value(1) works, with T is inferred to be int.
3938 @overload
40- def __init__ (self , value : MISSING_TYPE , * , read_only : bool = False ) -> None :
39+ def __init__ (
40+ self , value : MISSING_TYPE = MISSING , * , read_only : bool = False
41+ ) -> None :
4142 ...
4243
4344 @overload
@@ -47,7 +48,7 @@ def __init__(self, value: T, *, read_only: bool = False) -> None:
4748 # If `value` is MISSING, then `get()` will raise a SilentException, until a new
4849 # value is set. Calling `unset()` will set the value to MISSING.
4950 def __init__ (
50- self , value : Union [T , MISSING_TYPE ], * , read_only : bool = False
51+ self , value : Union [T , MISSING_TYPE ] = MISSING , * , read_only : bool = False
5152 ) -> None :
5253 self ._value : T = value
5354 self ._read_only : bool = read_only
0 commit comments