Skip to content

1.4.0 regression: enum.member(value=callable) leaves the wrapper in self.value #5279

Open

Description

@adamtheturtle

Describe the bug

The keyword form member(value=decimal) is valid and works at runtime. In 1.4.0, replacing it with member(decimal) makes the diagnostic disappear. The annotation is a normal callable payload contract; no suppression is needed with 1.3.2.

Reproduced with Pyrefly 1.4.0 and CPython 3.14.8 on macOS. Pyrefly 1.3.2 accepts the same example under --preset all.

Reproducer

from collections.abc import Callable
from enum import Enum, member

def decimal(value: int, /) -> str:
    return str(value)

class Format(Enum):
    DECIMAL = member(value=decimal)

    def render(self, value: int, /) -> str:
        formatter: Callable[[int], str] = self.value
        return formatter(value)

assert Format.DECIMAL.render(42) == "42"

Commands

uvx --from pyrefly==1.3.2 pyrefly check --preset all callable_member.py
uvx --from pyrefly==1.4.0 pyrefly check --preset all callable_member.py
python callable_member.py

The runtime assertion passes. The configuration only sets preset = "all" and python-version = "3.14".

Pyrefly 1.4.0 output

`member[(value: int, /) -> str]` is not assignable to `(int) -> str` [bad-assignment]

Mypy 2.4.0 (strict, without project plugins) and Pyright 1.1.414 accept this example.

Activity

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