Skip to content

Commit

Permalink
Add exhaustive check for mypy
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rexledesma committed May 17, 2021
1 parent 0f11c3b commit 3d0c3cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python_modules/dagster/dagster/check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,7 @@ def class_param(obj: Any, param_name: str) -> Union[ParameterCheckError, type]:
f'Param "{param_name}" is not a class. Got {repr(obj)} which is type {type(obj)}.'
)
return obj


def assert_never(value: NoReturn) -> NoReturn:
failed(f"Unhandled value: {value} ({type(value).__name__})")

1 comment on commit 3d0c3cb

@vercel
Copy link

@vercel vercel bot commented on 3d0c3cb May 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.