enums_expansion error

assert_type with LiteralEnum.MEMBER on enum-typed param

This rule detects when assert_type() is used with a LiteralEnum.MEMBER type on a parameter that is already typed as the enum itself. This is redundant and indicates a misunderstanding of enum typing semantics.

from enum import Enum
from typing import assert_type, Literal

class Status(Enum):
    ACTIVE = 1
    INACTIVE = 2

def process(status: Status) -> None:
    assert_type(status, Literal[Status.ACTIVE])  # E0061 — redundant narrowing
    assert_type(status, Status)                  # OK — correct usage

How to handle it

Every rule is on by default — strict is the default, not a cage. You can dial enums_expansion 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/enums_expansion