Skip to content

Commit 11289db

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4d61b4b commit 11289db

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

mypy/options.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class BuildType:
8585
NEW_GENERIC_SYNTAX: Final = "NewGenericSyntax"
8686
INLINE_TYPEDDICT: Final = "InlineTypedDict"
8787
TYPE_FORM: Final = "TypeForm"
88-
INCOMPLETE_FEATURES: Final = frozenset(
89-
(PRECISE_TUPLE_TYPES, INLINE_TYPEDDICT, TYPE_FORM)
90-
)
88+
INCOMPLETE_FEATURES: Final = frozenset((PRECISE_TUPLE_TYPES, INLINE_TYPEDDICT, TYPE_FORM))
9189
COMPLETE_FEATURES: Final = frozenset((TYPE_VAR_TUPLE, UNPACK, NEW_GENERIC_SYNTAX))
9290

9391

@@ -474,10 +472,7 @@ def process_error_codes(self, *, error_callback: Callable[[str], Any]) -> None:
474472
self.enabled_error_codes -= self.disabled_error_codes
475473

476474
def process_incomplete_features(
477-
self,
478-
*,
479-
error_callback: Callable[[str], Any],
480-
warning_callback: Callable[[str], Any],
475+
self, *, error_callback: Callable[[str], Any], warning_callback: Callable[[str], Any]
481476
) -> None:
482477
# Validate incomplete features.
483478
for feature in self.enable_incomplete_feature:
@@ -552,12 +547,8 @@ def build_per_module_cache(self) -> None:
552547
# than foo.bar.*.
553548
# (A section being "processed last" results in its config "winning".)
554549
# Unstructured glob configs are stored and are all checked for each module.
555-
unstructured_glob_keys = [
556-
k for k in self.per_module_options.keys() if "*" in k[:-1]
557-
]
558-
structured_keys = [
559-
k for k in self.per_module_options.keys() if "*" not in k[:-1]
560-
]
550+
unstructured_glob_keys = [k for k in self.per_module_options.keys() if "*" in k[:-1]]
551+
structured_keys = [k for k in self.per_module_options.keys() if "*" not in k[:-1]]
561552
wildcards = sorted(k for k in structured_keys if k.endswith(".*"))
562553
concrete = [k for k in structured_keys if not k.endswith(".*")]
563554

@@ -575,9 +566,7 @@ def build_per_module_cache(self) -> None:
575566
# on inheriting from parent configs.
576567
options = self.clone_for_module(key)
577568
# And then update it with its per-module options.
578-
self._per_module_cache[key] = options.apply_changes(
579-
self.per_module_options[key]
580-
)
569+
self._per_module_cache[key] = options.apply_changes(self.per_module_options[key])
581570

582571
# Add the more structured sections into unused configs, since
583572
# they only count as used if actually used by a real module.

mypyc/test/test_options.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# test/testopts.py (or similar file)
22

3-
from mypy.errorcodes import error_codes, ErrorCode
3+
import unittest # or another framework used by mypy
4+
5+
from mypy.errorcodes import error_codes
46
from mypy.options import Options
5-
import unittest # or another framework used by mypy
67

78
# Get the specific ErrorCode object we are testing
8-
POSSIBLY_UNDEFINED = error_codes['possibly-undefined']
9+
POSSIBLY_UNDEFINED = error_codes["possibly-undefined"]
10+
911

1012
class OptionsPrecedenceSuite(unittest.TestCase):
1113
# ... other test methods ...
@@ -19,8 +21,8 @@ def test_global_disable_precedence(self) -> None:
1921
"""
2022
options = Options()
2123
# 1. Simulate both being set in config/command line
22-
options.enable_error_code = ['possibly-undefined']
23-
options.disable_error_code = ['possibly-undefined']
24+
options.enable_error_code = ["possibly-undefined"]
25+
options.disable_error_code = ["possibly-undefined"]
2426

2527
# 2. Run the processing logic (this is where your fix lives)
2628
options.process_error_codes(error_callback=lambda x: None)
@@ -35,21 +37,21 @@ def test_per_module_disable_precedence(self) -> None:
3537
(Tests Options.apply_changes)
3638
"""
3739
base_options = Options()
38-
40+
3941
# 1. Setup the global options to ENABLE the code
40-
base_options.enable_error_code = ['possibly-undefined']
42+
base_options.enable_error_code = ["possibly-undefined"]
4143
base_options.process_error_codes(error_callback=lambda x: None)
42-
44+
4345
# 2. Setup a per-module override to DISABLE the code
4446
per_module_changes = {
45-
'disable_error_code': ['possibly-undefined'],
46-
'enable_error_code': [], # ensure this list doesn't interfere
47+
"disable_error_code": ["possibly-undefined"],
48+
"enable_error_code": [], # ensure this list doesn't interfere
4749
}
48-
50+
4951
# 3. Apply the per-module changes (this is where your fix lives)
5052
# We don't care about the module name here, just the application of changes.
5153
module_options = base_options.apply_changes(per_module_changes)
52-
54+
5355
# 4. Assert the result: DISABLE must win at the module level
5456
self.assertIn(POSSIBLY_UNDEFINED, module_options.disabled_error_codes)
55-
self.assertNotIn(POSSIBLY_UNDEFINED, module_options.enabled_error_codes)
57+
self.assertNotIn(POSSIBLY_UNDEFINED, module_options.enabled_error_codes)

0 commit comments

Comments
 (0)