[issue45535] Enum's dir() does not contain inherited members

2022-01-18 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 7c0914d35eaaab2f323260ba5fe8884732533888 by Ethan Furman in 
branch 'main':
bpo-45535: [Enum] include special dunders in dir() (GH-30677)
https://github.com/python/cpython/commit/7c0914d35eaaab2f323260ba5fe8884732533888


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2022-01-18 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +28877
pull_request: https://github.com/python/cpython/pull/30677

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2022-01-17 Thread Ethan Furman


Ethan Furman  added the comment:

Fixed in 3.11.

Pure enums have a few more dir() entries now; mixed enums now show all 
inherited methods/attributes -- members still do not show up in member dirs 
(this is a good thing).

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
superseder:  -> Enum: modify __repr__, __str__; update docs

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-12-02 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset b2afdc95cc8f4e9228148730949a43cef0323f15 by Alex Waygood in 
branch 'main':
bpo-45535: Improve output of Enum ``dir()`` (GH-29316)
https://github.com/python/cpython/commit/b2afdc95cc8f4e9228148730949a43cef0323f15


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-29 Thread Alex Waygood


Alex Waygood  added the comment:

I would argue it's quite important for `IntEnum` to have the dunder methods 
inherited from `int` show up in `help()`. Dunder methods indicate that an 
object has certain behaviours, so it's important for a user to be able to 
verify that an `IntEnum` member has similar behaviours to an `int` instance. 
`IntEnum` is advertised in the documentation as something that can be used 
everywhere where an integer is expected; it's surprising when the output from 
`help()` is hugely abbreviated for `IntEnum` relative to `int`.

But, I agree that my first draft of this PR is more complex than I'd like it to 
be.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-29 Thread Ethan Furman


Ethan Furman  added the comment:

Enums have had a custom dir() from the beginning, partly because they are not 
standard objects and do not follow standard rules.

The question posed by this issue is whether Enums with mixed-in data types 
should show the inherited methods, and if yes, should it also show inherited 
`__dunders__`.

I'm inclined to say yes for the normal inherited methods, I'm not sure about 
inherited `__dunders__`.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-29 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 29316 looks complicated.

First of all, why do Enum needs a custom __dir__? What is wrong with the 
default implementation?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-29 Thread Alex Waygood


Change by Alex Waygood :


--
keywords: +patch
pull_requests: +27585
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29316

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-22 Thread Alex Waygood


Alex Waygood  added the comment:

Would there be interest in me submitting a PR along these lines?



> why use mro() instead of __mro__?

Er, no reason, really. To be honest, I've never really understood why Python 
has both.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There may be a simple error (superfluous .__class__), but I am not sure.

BTW, why use mro() instead of __mro__? Most code use __mro__.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-21 Thread Ethan Furman


Change by Ethan Furman :


--
assignee:  -> ethan.furman
versions:  -Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-21 Thread Ethan Furman


Ethan Furman  added the comment:

Looks interesting, thank you for the patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-21 Thread Alex Waygood


Change by Alex Waygood :


Added file: https://bugs.python.org/file50383/enum_dir_output_with_patch.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-21 Thread Alex Waygood


Alex Waygood  added the comment:

I had a go at writing a patch for `__dir__` that would include any methods an 
enum class had acquired through `int`/`str`/etc. mixins, while continuing to 
ignore enum dunders and sunders (as is currently the case). My patch also 
allows user-defined methods defined in enum subclasses to show up in the 
`help()` output, whereas they currently do not, since `help(enum_member)` looks 
up `dir(enum_class)` rather than `dir(enum_member)`.

The patch is a fair way more complex than the the existing code, however.

--
nosy: +AlexWaygood
Added file: https://bugs.python.org/file50382/Enum_dir_patch.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45535] Enum's dir() does not contain inherited members

2021-10-20 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

For example:

>>> from enum import *
>>> class E(IntEnum):
... x = 1
... 
>>> dir(E)
['__class__', '__doc__', '__members__', '__module__', 'x']
>>> E.from_bytes

>>> E.to_bytes

>>> E.numerator

>>> E.__add__


There are methods and attributes inherited from int, but they are not shown in 
dir(). As result they are absent in help() and completion does not work for 
them.

--
components: Library (Lib)
messages: 404420
nosy: barry, eli.bendersky, ethan.furman, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Enum's dir() does not contain inherited members
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com