Skip to content

[Module Explorer] Enum members are counted as untyped even though annotations are forbidden #373

Description

@rayliverified

Summary

Module Explorer counts valid Enum/StrEnum members as untyped because they do not have explicit annotations. However, PEP 435 enum members are inferred from their assignments and must be left unannotated. Basilisk's own enums_members diagnostic correctly rejects the annotation that would otherwise satisfy the coverage metric.

This makes the type-coverage percentage impossible to reach 100% in projects that use enums correctly.

Minimal reproduction

from enum import StrEnum


class Status(StrEnum):
    ACTIVE = "active"
    INACTIVE = "inactive"

Steps to reproduce

  1. Open the file in a Basilisk workspace.
    1. Run basilisk check — it passes.
    1. Expand the module and Status in Module Explorer.
    1. Observe that ACTIVE and INACTIVE are labeled untyped and reduce the module/workspace coverage percentage.
    1. Attempt to add an explicit annotation:
class Status(StrEnum):
    ACTIVE: str = "active"
  1. Run basilisk check again.

Actual behavior

The valid plain enum members are counted as untyped. Adding an annotation produces the expected error:

error[enums_members]: Enum member `ACTIVE` in `Status` should not have an explicit type annotation

The diagnostic correctly notes that enum members have an inferred Literal[Status.ACTIVE] type.

Expected behavior

Enum members should either:

  1. Count as typed using their inferred Literal[EnumClass.MEMBER] type, or
    1. Be excluded from the explicit-annotation coverage denominator.
      The coverage metric should not require syntax that the type specification and Basilisk itself prohibit.

Impact

In a real Python 3.12 project, Module Explorer reports 33 enum members as untyped across otherwise fully annotated modules. This lowers raw workspace coverage and forces downstream coverage gates to special-case enum members.

Environment

  • Basilisk / VS Code extension: 0.38.0
    • Python: 3.12
      • OS: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions