Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50717cf

Browse files
authored
Improve misleading message in Enum() (#5317) (#14590)
Clarifying this is a mypy limitation, not an Enum() requirementNot a true fix, but a workaround for#5317 to avoid confusion (as seenby the many duplicates)
1 parent0929773 commit50717cf

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

‎mypy/semanal_enum.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ def parse_enum_call_args(
220220
items.append(field)
221221
else:
222222
returnself.fail_enum_call_arg(
223-
"%s()expects a string, tuple, list or dict literalas the second argument"
223+
"Second argument of%s()must be string, tuple, list or dict literalfor mypy to determine Enum members"
224224
%class_name,
225225
call,
226226
)
227227
else:
228228
# TODO: Allow dict(x=1, y=2) as a substitute for {'x': 1, 'y': 2}?
229229
returnself.fail_enum_call_arg(
230-
"%s()expects a string, tuple, list or dict literalas the second argument"
230+
"Second argument of%s()must be string, tuple, list or dict literalfor mypy to determine Enum members"
231231
%class_name,
232232
call,
233233
)

‎test-data/unit/check-enum.test‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,13 @@ W.c
482482
[typing fixtures/typing-medium.pyi]
483483
[out]
484484
main:2: error: Too few arguments for Enum()
485-
main:3: error: Enum()expects a string, tuple, list or dict literalas the second argument
485+
main:3: error:Second argument ofEnum()must be string, tuple, list or dict literalfor mypy to determine Enum members
486486
main:4: error: Too many arguments for Enum()
487-
main:5: error: Enum()expects a string, tuple, list or dict literalas the second argument
487+
main:5: error:Second argument ofEnum()must be string, tuple, list or dict literalfor mypy to determine Enum members
488488
main:5: error: Name "foo" is not defined
489-
main:7: error: Enum()expects a string, tuple, list or dict literalas the second argument
489+
main:7: error:Second argument ofEnum()must be string, tuple, list or dict literalfor mypy to determine Enum members
490490
main:8: error: Too few arguments for IntEnum()
491-
main:9: error: IntEnum()expects a string, tuple, list or dict literalas the second argument
491+
main:9: error:Second argument ofIntEnum()must be string, tuple, list or dict literalfor mypy to determine Enum members
492492
main:10: error: Too many arguments for IntEnum()
493493
main:11: error: Enum() needs at least one item
494494
main:12: error: Enum() needs at least one item

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp