Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnumType __call__ method description does not match the implementation #119110

Open
Mi-La opened this issue May 17, 2024 · 1 comment
Open

EnumType __call__ method description does not match the implementation #119110

Mi-La opened this issue May 17, 2024 · 1 comment
Assignees
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir

Comments

@Mi-La
Copy link

Mi-La commented May 17, 2024

Documentation

See EnumType.call documentation, where the prototype is:

__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

While in the enum.py source code there is:

def __call__(cls, value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None):
  1. The _not_given helper behaves differently than None, which even breaks compatibility with previous versions (this change was introduced in 3.12.3), when one needs to do some customization of enum metaclass.

    • e.g. as propsed on the stack overflow to implement enum item deprecation warning - note that this implementation stops working in 3.12.3 since the call of the parent EnumType.__call__ passes None instead of _not_given and it causes different behavior.
  2. Note * vs. *values, which I believe even behaves differently.

@Mi-La Mi-La added the docs Documentation in the Doc dir label May 17, 2024
@Eclips4 Eclips4 added the stdlib Python modules in the Lib dir label May 17, 2024
@Mi-La
Copy link
Author

Mi-La commented May 17, 2024

@ethanfurman It seems that the SO answer I mentioned above is yours :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir
3 participants