You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1243,3 +1243,59 @@ class Comparator(enum.Enum):
reveal_type(Comparator.__foo__) # N: Revealed type is 'builtins.dict[builtins.str, builtins.int]'
[builtins fixtures/dict.pyi]
[case testEnumWithInstanceAttributes]
from enum import Enum
class Foo(Enum):
def __init__(self, value: int) -> None:
self.foo = "bar"
A = 1
B = 2
a = Foo.A
reveal_type(a.value) # N: Revealed type is 'builtins.int'
reveal_type(a._value_) # N: Revealed type is 'builtins.int'
[case testNewSetsUnexpectedValueType]
from enum import Enum
class bytes:
def __new__(cls): pass
class Foo(bytes, Enum):
def __new__(cls, value: int) -> 'Foo':
obj = bytes.__new__(cls)
obj._value_ = "Number %d" % value
return obj
A = 1
B = 2
a = Foo.A
reveal_type(a.value) # N: Revealed type is 'Any'
reveal_type(a._value_) # N: Revealed type is 'Any'
[builtins fixtures/__new__.pyi]
[builtins fixtures/primitives.pyi]
[typing fixtures/typing-medium.pyi]
[case testValueTypeWithNewInParentClass]
from enum import Enum
class bytes:
def __new__(cls): pass
class Foo(bytes, Enum):
def __new__(cls, value: int) -> 'Foo':
obj = bytes.__new__(cls)
obj._value_ = "Number %d" % value
return obj
class Bar(Foo):
A = 1
B = 2
a = Bar.A
reveal_type(a.value) # N: Revealed type is 'Any'
reveal_type(a._value_) # N: Revealed type is 'Any'
[builtins fixtures/__new__.pyi]
[builtins fixtures/primitives.pyi]
[typing fixtures/typing-medium.pyi]
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix recentl 8000 y added enum value type prediction #10057
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
Fix recently added enum value type prediction #10057
Changes from all commits
585152b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing