Skip to content

Commit 5038765

Browse files
author
Guido van Rossum
committed
Respond to review by @ilevkivskyi
1 parent d6c543b commit 5038765

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,7 @@ def parse_enum_call_args(self, call: CallExpr,
20962096
values.append(value)
20972097
else:
20982098
return self.fail_enum_call_arg(
2099-
"%s() with tuple or list of (name, value) pairs not yet supported" %
2099+
"%s() with tuple or list expects strings or (name, value) pairs" %
21002100
class_name,
21012101
call)
21022102
elif isinstance(args[1], DictExpr):

test-data/unit/pythoneval-enum.test

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ _program.py:7: error: Revealed type is 'builtins.int'
150150
[case testFunctionalEnumListOfStrings]
151151
from enum import Enum, IntEnum
152152
E = Enum('E', ('foo', 'bar'))
153-
F = Enum('F', ['bar', 'baz'])
153+
F = IntEnum('F', ['bar', 'baz'])
154154
reveal_type(E.foo)
155155
reveal_type(F.baz)
156156
[out]
@@ -160,7 +160,7 @@ _program.py:5: error: Revealed type is '_testFunctionalEnumListOfStrings.F'
160160
[case testFunctionalEnumListOfPairs]
161161
from enum import Enum, IntEnum
162162
E = Enum('E', [('foo', 1), ['bar', 2]])
163-
F = Enum('F', (['bar', 1], ('baz', 2)))
163+
F = IntEnum('F', (['bar', 1], ('baz', 2)))
164164
reveal_type(E.foo)
165165
reveal_type(F.baz)
166166
reveal_type(E.foo.value)
@@ -202,6 +202,7 @@ N = IntEnum('M', [])
202202
P = Enum('P', [42])
203203
Q = Enum('Q', [('a', 42, 0)])
204204
R = IntEnum('R', [[0, 42]])
205+
S = Enum('S', {1: 1})
205206
[out]
206207
_program.py:2: error: Too few arguments for Enum()
207208
_program.py:3: error: Enum() expects a string, tuple, list or dict literal as the second argument
@@ -215,6 +216,7 @@ _program.py:10: error: Too many arguments for IntEnum()
215216
_program.py:11: error: Enum() needs at least one item
216217
_program.py:12: error: Enum() needs at least one item
217218
_program.py:13: error: IntEnum() needs at least one item
218-
_program.py:14: error: Enum() with tuple or list of (name, value) pairs not yet supported
219-
_program.py:15: error: Enum() with tuple or list of (name, value) pairs not yet supported
220-
_program.py:16: error: IntEnum() with tuple or list of (name, value) pairs not yet supported
219+
_program.py:14: error: Enum() with tuple or list expects strings or (name, value) pairs
220+
_program.py:15: error: Enum() with tuple or list expects strings or (name, value) pairs
221+
_program.py:16: error: IntEnum() with tuple or list expects strings or (name, value) pairs
222+
_program.py:17: error: Enum() with dict literal requires string literals

0 commit comments

Comments
 (0)