Skip to content

Revert "Add __new__ to str and int stubs in both Pythons. (#1352)" - #1466

Merged
matthiaskramm merged 1 commit into
python:masterfrom
JelleZijlstra:revert1352
Jul 6, 2017
Merged

matthiaskramm merged 1 commit into
python:masterfrom
JelleZijlstra:revert1352

Conversation

@JelleZijlstra

Copy link
Copy Markdown
Member

This reverts commit fed4e03.

See #1464.

This doesn't completely fix #1464; I still get "bin/enumindex.py:9: error: Value of type Type[I] is not indexable" for an enum inheriting from int and Enum. But some of the errors are gone.

Comment thread third_party/2/enum.pyi

class IntEnum(int, Enum): # type: ignore
def __new__(cls: Type[_T], value: Any) -> _T: ...
class IntEnum(int, Enum): ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're removing the explicit __new__, would it make sense to make the base class order "Enum, int" so that __new__ is inherited from Enum, not int?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also removed __new__ from int, so I don't think that makes a difference. Int comes first at runtime (https://github.com/python/cpython/blob/master/Lib/enum.py#L639), so putting Enum first here will probably break something.

@matthiaskramm
matthiaskramm merged commit 16aa065 into python:master Jul 6, 2017
@JelleZijlstra
JelleZijlstra deleted the revert1352 branch May 30, 2020 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with enum indexing

2 participants