literals_parameterizations_2
error
Literal"EnumClass.MEMBER" (string) used where LiteralEnumClass.MEMBER (enum member reference) is required
A quoted string like "Color.RED" is a str literal — it is NOT the same as the enum member Color.RED. When a variable is declared as LiteralColor.RED but assigned from a parameter typed as Literal"Color.RED", the types are incompatible.
from enum import Enum
from typing import Literal
class Color(Enum):
RED = 1
def func2(a: Literal[Color.RED]) -> None:
x1: Literal["Color.RED"] = a # E — string literal != enum member
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
literals_parameterizations_2 down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/literals_parameterizations_2