Skip to content

Commit 228bd29

Browse files
ilevkivskyiIvan Levkivskyi
authored and
Ivan Levkivskyi
committed
Fix error codes option serialization (#13523)
Fixes #13521
1 parent 1f80611 commit 228bd29

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
@@ -467,7 +467,7 @@ def select_options_affecting_cache(self) -> Mapping[str, object]:
467467
result: Dict[str, object] = {}
468468
for opt in OPTIONS_AFFECTING_CACHE:
469469
val = getattr(self, opt)
470-
if isinstance(val, set):
471-
val = sorted(val)
470+
if opt in ("disabled_error_codes", "enabled_error_codes"):
471+
val = sorted([code.code for code in val])
472472
result[opt] = val
473473
return result

test-data/unit/check-incremental.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5980,3 +5980,13 @@ foo(name='Jennifer', age="38")
59805980
[out]
59815981
[out2]
59825982
tmp/m.py:2: error: Argument "age" to "foo" has incompatible type "str"; expected "int"
5983+
5984+
[case testDisableEnableErrorCodesIncremental]
5985+
# flags: --disable-error-code truthy-bool
5986+
# flags2: --enable-error-code truthy-bool
5987+
def foo() -> int: ...
5988+
if foo:
5989+
...
5990+
[out]
5991+
[out2]
5992+
main:4: error: Function "Callable[[], int]" could always be true in boolean context

0 commit comments

Comments
 (0)