Skip to content

False positive "Method must have at least one argument" with @enum.member #18720

@sterliakov

Description

@sterliakov

Bug Report

enum.member-decorated functions become enum members and do not undergo self binding, similar to static methods. The repro snippet can be run with python 3.11 and newer to confirm.

To Reproduce

playground

from enum import Enum, member
from typing import reveal_type

class E(Enum):
    @member
    def A() -> int:
        return 1

assert E.A.value() == 1
reveal_type(E.A)
reveal_type(E.A.value)

Expected Behavior

Green output.

Actual Behavior

main.py:6: error: Method must have at least one argument. Did you forget the "self" argument?  [misc]
main.py:10: note: Revealed type is "enum.member[def () -> builtins.int]"
main.py:11: note: Revealed type is "def () -> builtins.int"

Your Environment

  • Mypy version used: 1.15.0 and current master
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions