Is there a way to make mypy happy with this code without changing class Config, at the moment I cannot change that class (using typer for a cli app). I am aware I can use # type: ignore but is there any other solution?
"""
mypy --version
mypy 0.812
"""
from enum import Enum
from pathlib import Path
from typing_extensions import Literal
class Config(str, Enum):
Debug = 'Debug'
Release = 'Release'
BuildMode = Literal["ASAN", "UBSAN", "Coverage", "Release", "Debug"]
def run_c_tests(results_dir: Path, mode: BuildMode):
...
configuration = Config.Debug
# mypy error: Argument 2 to "run_c_tests" has incompatible type "str"; expected "Union[Literal['ASAN'], Literal['UBSAN'], Literal['Coverage'], Literal['Release'], Literal['Debug']]"
run_c_tests(Path('apath'), configuration.value)
Mypy v0.782 does not complain on the code above but 0.812 does.