Skip to content

Generalize reachability checks to support enums #7000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 8, 2019
Prev Previous commit
Next Next commit
Update comment
  • Loading branch information
Michael0x2a committed Jul 8, 2019
commit d1d99a7c0b56181ffca4ac4487fa824b58c27436
9 changes: 7 additions & 2 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4536,8 +4536,13 @@ class Color(Enum):
BLUE = 2
YELLOW = 3

...and if we call `try_expanding_enum_to_union(color_instance, 'module.Color')`,
this function will return Literal[Color.RED, Color.BLUE, Color.YELLOW].
class Status(Enum):
SUCCESS = 1
FAILURE = 2
UNKNOWN = 3

...and if we call `try_expanding_enum_to_union(Union[Color, Status], 'module.Color')`,
this function will return Literal[Color.RED, Color.BLUE, Color.YELLOW, Status].
"""
if isinstance(typ, UnionType):
new_items = [try_expanding_enum_to_union(item, target_fullname)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy