pg.enable_type_check¶
Accessible via pg.enable_type_check
, pg.symbolic.enable_type_check
.
- enable_type_check(enabled=True)[source]¶
Returns a context manager to enable or disable runtime type check.
enable_type_check is thread-safe and can be nested. For example, in the following code, runtime type check with be a but not on b:
with pg.enable_type_check(False): with pg.enable_type_check(True): a = pg.Dict(x=1, value_spec=pg.typing.Dict([('x', pg.typing.Int())])) b = pg.Dict(y=1, value_spec=pg.typing.Dict([('x', pg.typing.Int())]))
- Return type:
- Parameters:
enabled – If True, enable runtime type check in current scope. Otherwise, disable runtime type check.
- Returns:
A context manager for allowing/disallowing runtime type check.