GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — It seems that `enum.Enum.__init__` serves no purpose · Issue #128080 · python/cpython

It seems that enum.Enum.__init__ serves no purpose #128080

New issue
Copy link
New issue
Copy link
Closed
Closed
It seems that enum.Enum.__init__ serves no purpose#128080
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@tungol
tungol
opened on Dec 18, 2024
Issue body actions

Feature or enhancement

Proposal:

Enum gained an __init__ method in 3.11 which just passes:

    def __init__(self, *args, **kwds):
        pass

That was added in #30582. One person questioned it at the time, but there was no response. The best I can figure is that it was related to special handling of __init__ in EnumType.__dir__, which you can see here:

cpython/Lib/enum.py

Lines 768 to 779 in 3852269

def __dir__(cls):
# TODO: check for custom __init__, __new__, __format__, __repr__, __str__, __init_subclass__
# on object-based enums
if cls._member_type_ is object:
interesting = set(cls._member_names_)
if cls._new_member_ is not object.__new__:
interesting.add('__new__')
if cls.__init_subclass__ is not object.__init_subclass__:
interesting.add('__init_subclass__')
for method in ('__init__', '__format__', '__repr__', '__str__'):
if getattr(cls, method) not in (getattr(Enum, method), getattr(Flag, method)):
interesting.add(method)

That special handling of __init__ was removed by #30677 prior to 3.11 being released, which leaves no plausible function to Enum.__init__ that I can see. It muddies introspection of the type, so I think we should remove it if that's really the case.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-128080: remove unnecessary __init__ method from Enum #128081

Activity

  1. tungol
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Dec 18, 2024
  2. ethanfurman
    added a commit that references this issue on Dec 19, 2024

    gh-128080: remove unnecessary `__init__` method from Enum (GH-128081)

    c14db20
  3. ethanfurman
    closed this as completedon Dec 19, 2024
  4. srinivasreddy
    added a commit that references this issue on Dec 23, 2024

    pythongh-128080: remove unnecessary `__init__` method from Enum (pyth…

    356306e
  5. srinivasreddy
    added a commit that references this issue on Jan 8, 2025

    pythongh-128080: remove unnecessary `__init__` method from Enum (pyth…

    343439f
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

    type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.