Page MenuHomeElementl

Add exhaustive check for mypy
ClosedPublic

Authored by rexledesma on Apr 28 2021, 8:17 PM.

Details

Summary

Ran into this when refactoring PartitionSetDefinition.

This idiom appears in https://hakibenita.com/python-mypy-exhaustive-checking and
https://github.com/python/mypy/issues/5818 - this is a nice to ensure exhaustion
when doing conditionals on enums.

Test Plan

N/A

Diff Detail

Repository
R1 dagster
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Example error if exhaustion is not met:

Screen Shot 2021-04-28 at 1.19.40 PM.png (442×1 px, 129 KB)

rexledesma retitled this revision from Add exhaustive check for mypy to [1/n] Add exhaustive check for mypy.Apr 29 2021, 1:10 AM

ah nice, I would use this frequently

This revision is now accepted and ready to land.Apr 29 2021, 1:28 PM
python_modules/dagster/dagster/check/__init__.py
112–116

*

865

im not sure about assert in run time code so probably safest to throw like check.failed does

rexledesma retitled this revision from [1/n] Add exhaustive check for mypy to Add exhaustive check for mypy.May 17 2021, 9:45 PM
This revision was automatically updated to reflect the committed changes.