Skip to content

Commit 3d0c3cb

Browse files
committed
Add exhaustive check for mypy
Summary: Ran into this when refactoring `PartitionSetDefinition`. This idiom appears in https://hakibenita.com/python-mypy-exhaustive-checking and python/mypy#5818 - this is a nice to ensure exhaustion when doing conditionals on enums. Test Plan: N/A Reviewers: dgibson, cdecarolis, alangenfeld Reviewed By: dgibson Differential Revision: https://dagster.phacility.com/D7642
1 parent 0f11c3b commit 3d0c3cb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python_modules/dagster/dagster/check/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,3 +859,7 @@ def class_param(obj: Any, param_name: str) -> Union[ParameterCheckError, type]:
859859
f'Param "{param_name}" is not a class. Got {repr(obj)} which is type {type(obj)}.'
860860
)
861861
return obj
862+
863+
864+
def assert_never(value: NoReturn) -> NoReturn:
865+
failed(f"Unhandled value: {value} ({type(value).__name__})")

0 commit comments

Comments
 (0)