Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Merged
merged 1 commit into from
Jul 6, 2017

Conversation

JelleZijlstra
Copy link
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.

@@ -16,7 +16,6 @@ class Enum(metaclass=EnumMeta):
name = ... # type: str
value = ... # type: Any

class IntEnum(int, Enum): # type: ignore
def __new__(cls: Type[_T], value: Any) -> _T: ...
class IntEnum(int, Enum): ...
Copy link
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
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