Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created June 10, 2026 08:46
Show Gist options
  • Select an option

  • Save mypy-play/b5db4d6e79381480dac2e843d472a508 to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/b5db4d6e79381480dac2e843d472a508 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from enum import StrEnum, auto
from dataclasses import dataclass
class E(StrEnum):
A = auto()
B = auto()
@dataclass()
class D:
e: E
def set_e(self, e: E) -> None:
self.e = e
def func(d: D, e: E) -> None:
reveal_type(d.e)
if d.e == E.A:
return
d.set_e(e)
reveal_type(d.e)
if d.e == E.A:
return
reveal_type(d.e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment