Skip to content

Enum.value explicit Any fallback is reported as unknown-attribute-access #5281

Closed

Description

@adamtheturtle

Describe the bug

The bundled typeshed declares Enum.value -> Any explicitly (1.4.0 stub). Reading it through the base Enum produces unknown-attribute-access, even when assigning it to object. The error-kind documentation says explicit Any accesses are intentional and not reported. I expected the explicit stub fallback to retain that distinction; I am not asking Pyrefly to infer a concrete payload from a bare Enum.

Reproduced with Pyrefly 1.4.0 and CPython 3.14.8 on macOS. Pyrefly 1.3.2 accepts this example with the same configuration. Mypy 2.4.0 (strict, without project plugins) and Pyright 1.1.414 also accept it.

Reproducer

from enum import Enum

def read_value(option: Enum) -> object:
    value: object = option.value
    return value

Save this as pyrefly.toml:

preset = "all"
python-version = "3.14"

Compare:

uvx --from pyrefly==1.3.2 pyrefly check --config pyrefly.toml enum_explicit_any.py
uvx --from pyrefly==1.4.0 pyrefly check --config pyrefly.toml enum_explicit_any.py

Pyrefly 1.4.0 output

The type of attribute `value` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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