GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Support exhaustiveness checking for 'in' statements (enums) · Issue #16093 · python/mypy Closed Malika1109/mypy #3Closed Copy link Labels DescriptionFeature Allow the use of the from enum import Enum from typing import assert_never class MyEnum(Enum): A = 1 B = 2 C = 3 def my_function(a: MyEnum) -> bool: if a == MyEnum.A: return True elif a in (MyEnum.B, MyEnum.C): return False assert_never(a) my_function(MyEnum.A) Currently, this will raise the following exception: where the following would not: def my_function(a: MyEnum) -> bool: if a == MyEnum.A: return True elif a == MyEnum.B: return False elif a == MyEnum.C: return False assert_never(a) Pitch If you wish to do the same thing for multiple enums in that particular function and also want exhaustiveness checking, you need to type each case out individually and then return the same thing, which is not great (DRY etc...). Reacted by Cal Jacobson, Oleg Levantin, Miikka Koskinen and quentin-ag Activity
MetadataMetadataAssigneesLabelsProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |