Skip to content

Commit 9e14aba

Browse files
authored
Fix error codes option serialization (#13523)
Fixes #13521
1 parent 3e9dd3c commit 9e14aba

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

mypy/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def select_options_affecting_cache(self) -> Mapping[str, object]:
456456
result: Dict[str, object] = {}
457457
for opt in OPTIONS_AFFECTING_CACHE:
458458
val = getattr(self, opt)
459-
if isinstance(val, set):
460-
val = sorted(val)
459+
if opt in ("disabled_error_codes", "enabled_error_codes"):
460+
val = sorted([code.code for code in val])
461461
result[opt] = val
462462
return result

test-data/unit/check-incremental.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6012,3 +6012,13 @@ foo(name='Jennifer', age="38")
60126012
[out]
60136013
[out2]
60146014
tmp/m.py:2: error: Argument "age" to "foo" has incompatible type "str"; expected "int"
6015+
6016+
[case testDisableEnableErrorCodesIncremental]
6017+
# flags: --disable-error-code truthy-bool
6018+
# flags2: --enable-error-code truthy-bool
6019+
def foo() -> int: ...
6020+
if foo:
6021+
...
6022+
[out]
6023+
[out2]
6024+
main:4: error: Function "Callable[[], int]" could always be true in boolean context

0 commit comments

Comments
 (0)