Bug Report
Using StrEnum's str.format without via an intermedium varible makes mypy unhappy.
To Reproduce
test.py:
from enum import StrEnum
class Animal(StrEnum):
DOG = "dog: {name}"
dog = Animal.DOG
print(dog.format(name="Goffy")) # mypy happy
print(Animal.DOG.format(name="Goffy")) # mypy unhappy
An alternative snippet for Python < 3.11:
from enum import Enum
class Animal(str, Enum):
DOG = "dog: {name}"
dog = Animal.DOG
print(dog.format(name="Goffy")) # mypy happy
print(Animal.DOG.format(name="Goffy")) # mypy unhappy
Expected Behavior
No error.
Actual Behavior
test.py:11: error: Not all arguments converted during string formatting [str-format]
Your Environment
- Mypy version used: 1.7.0
- Mypy command-line flags: Literally none. (i.e.,
$ mypy test.py)
- Mypy configuration options from
mypy.ini (and other config files): None.
- Python version used: 3.12.0
Bug Report
Using
StrEnum'sstr.formatwithout via an intermedium varible makes mypy unhappy.To Reproduce
test.py:An alternative snippet for
Python < 3.11:Expected Behavior
No error.
Actual Behavior
Your Environment
$ mypy test.py)mypy.ini(and other config files): None.