Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster/dagster/check/__init__.py
Show First 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | |||||
def opt_bool_param(obj: Any, param_name: str, default: bool = None) -> Optional[bool]: | def opt_bool_param(obj: Any, param_name: str, default: bool = None) -> Optional[bool]: | ||||
if obj is not None and not isinstance(obj, bool): | if obj is not None and not isinstance(obj, bool): | ||||
raise _param_type_mismatch_exception(obj, bool, param_name) | raise _param_type_mismatch_exception(obj, bool, param_name) | ||||
return default if obj is None else obj | return default if obj is None else obj | ||||
def bytes_param(obj: Any, param_name: str) -> bytes: | |||||
if not isinstance(obj, bytes): | |||||
raise _param_type_mismatch_exception(obj, bytes, param_name) | |||||
return obj | |||||
def opt_bytes_param(obj: Any, param_name: str, default: bytes = None) -> Optional[bytes]: | |||||
if obj is not None and not isinstance(obj, bytes): | |||||
raise _param_type_mismatch_exception(obj, bytes, param_name) | |||||
return default if obj is None else obj | |||||
def is_list(obj_list: Any, of_type: Type = None, desc: str = None) -> List: | def is_list(obj_list: Any, of_type: Type = None, desc: str = None) -> List: | ||||
if not isinstance(obj_list, list): | if not isinstance(obj_list, list): | ||||
raise _type_mismatch_error(obj_list, list, desc) | raise _type_mismatch_error(obj_list, list, desc) | ||||
if not of_type: | if not of_type: | ||||
return obj_list | return obj_list | ||||
return _check_list_items(obj_list, of_type) | return _check_list_items(obj_list, of_type) | ||||
▲ Show 20 Lines • Show All 578 Lines • Show Last 20 Lines |