From 9e14abaac7e432319f217cc6b8e17ccbe840720f Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 26 Aug 2022 16:12:23 +0100 Subject: [PATCH] Fix error codes option serialization (#13523) Fixes #13521 --- mypy/options.py | 4 ++-- test-data/unit/check-incremental.test | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mypy/options.py b/mypy/options.py index 6babd0f028d1..fb7bb8e43bbb 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -456,7 +456,7 @@ def select_options_affecting_cache(self) -> Mapping[str, object]: result: Dict[str, object] = {} for opt in OPTIONS_AFFECTING_CACHE: val = getattr(self, opt) - if isinstance(val, set): - val = sorted(val) + if opt in ("disabled_error_codes", "enabled_error_codes"): + val = sorted([code.code for code in val]) result[opt] = val return result diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 599b00dabe3d..bf011140df86 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -6012,3 +6012,13 @@ foo(name='Jennifer', age="38") [out] [out2] tmp/m.py:2: error: Argument "age" to "foo" has incompatible type "str"; expected "int" + +[case testDisableEnableErrorCodesIncremental] +# flags: --disable-error-code truthy-bool +# flags2: --enable-error-code truthy-bool +def foo() -> int: ... +if foo: + ... +[out] +[out2] +main:4: error: Function "Callable[[], int]" could always be true in boolean context