[New-bugs-announce] [issue46296] Unreachable condition: `if enum_class._member_type_ is object`

Nikita Sobolev report at bugs.python.org
Fri Jan 7 12:36:29 EST 2022


New submission from Nikita Sobolev <mail at sobolevn.me>:

This condition can never be `True`: https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Lib/enum.py#L222-L223

Why? Because: 
1. It is executed only when `if not enum_class._use_args_:`: https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Lib/enum.py#L215
2. But, `enum_class._use_args_` will always be `False` for cases when `enum_class._member_type_` is `object`
3. It is defined here: https://github.com/python/cpython/blob/b127e70a8a682fe869c22ce04c379bd85a00db67/Lib/enum.py#L937

So, I guess that removing this condition can simplify the `enum.py`.
Coverage shows that this part is not tested.

I will send a PR shortly.

----------
components: Library (Lib)
messages: 409989
nosy: sobolevn
priority: normal
severity: normal
status: open
title: Unreachable condition: `if enum_class._member_type_ is object`
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46296>
_______________________________________


More information about the New-bugs-announce mailing list