Skip to content

Commit 5d63463

Browse files
authored
1 parent dd55b66 commit 5d63463

File tree

15 files changed

+36
-72
lines changed

15 files changed

+36
-72
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 25.9.0
9+
rev: 26.1.0
1010
hooks:
1111
- id: black
1212
exclude: '^(test-data/)'

misc/sync-typeshed.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,12 @@ def main() -> None:
184184
assert commit
185185

186186
# Create a commit
187-
message = textwrap.dedent(
188-
f"""\
187+
message = textwrap.dedent(f"""\
189188
Sync typeshed
190189
191190
Source commit:
192191
https://github.com/python/typeshed/commit/{commit}
193-
"""
194-
)
192+
""")
195193
subprocess.run(["git", "add", "--all", os.path.join("mypy", "typeshed")], check=True)
196194
subprocess.run(["git", "commit", "-m", message], check=True)
197195
print("Created typeshed sync commit.")

mypy/build.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,12 +1432,10 @@ def exclude_from_backups(target_dir: str) -> None:
14321432
cachedir_tag = os.path.join(target_dir, "CACHEDIR.TAG")
14331433
try:
14341434
with open(cachedir_tag, "x") as f:
1435-
f.write(
1436-
"""Signature: 8a477f597d28d172789f06886806bc55
1435+
f.write("""Signature: 8a477f597d28d172789f06886806bc55
14371436
# This file is a cache directory tag automatically created by mypy.
14381437
# For information about cache directory tags see https://bford.info/cachedir/
1439-
"""
1440-
)
1438+
""")
14411439
except FileExistsError:
14421440
pass
14431441

mypy/checkexpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,7 @@ def infer_function_type_arguments(
21162116

21172117
if 2 in arg_pass_nums:
21182118
# Second pass of type inference.
2119-
(callee_type, inferred_args) = self.infer_function_type_arguments_pass2(
2119+
callee_type, inferred_args = self.infer_function_type_arguments_pass2(
21202120
callee_type,
21212121
args,
21222122
arg_kinds,
@@ -6462,7 +6462,7 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> Type | No
64626462
# Collect symbols targeted by NameExprs and MemberExprs,
64636463
# to be looked up by TypeAnalyser when binding the
64646464
# UnboundTypes corresponding to those expressions.
6465-
(name_exprs, member_exprs) = all_name_and_member_expressions(maybe_type_expr)
6465+
name_exprs, member_exprs = all_name_and_member_expressions(maybe_type_expr)
64666466
sym_for_name = {e.name: SymbolTableNode(UNBOUND_IMPORTED, e.node) for e in name_exprs} | {
64676467
e_name: SymbolTableNode(UNBOUND_IMPORTED, e.node)
64686468
for e in member_exprs

mypy/checkpattern.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType:
312312
narrowed_inner_types = []
313313
inner_rest_types = []
314314
for inner_type, new_inner_type in zip(inner_types, new_inner_types):
315-
(narrowed_inner_type, inner_rest_type) = (
315+
narrowed_inner_type, inner_rest_type = (
316316
self.chk.conditional_types_with_intersection(
317317
inner_type, [get_type_range(new_inner_type)], o, default=inner_type
318318
)

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def fix_function_overloads(self, stmts: list[Statement]) -> list[Statement]:
634634
# Check IfStmt block to determine if function overloads can be merged
635635
if_overload_name = self._check_ifstmt_for_overloads(stmt, current_overload_name)
636636
if if_overload_name is not None:
637-
(if_block_with_overload, if_unknown_truth_value) = (
637+
if_block_with_overload, if_unknown_truth_value = (
638638
self._get_executable_if_block_with_overloads(stmt)
639639
)
640640

mypy/messages.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,17 +1295,13 @@ def argument_incompatible_with_supertype(
12951295
)
12961296

12971297
def comparison_method_example_msg(self, class_name: str) -> str:
1298-
return dedent(
1299-
"""\
1298+
return dedent("""\
13001299
It is recommended for "__eq__" to work with arbitrary objects, for example:
13011300
def __eq__(self, other: object) -> bool:
13021301
if not isinstance(other, {class_name}):
13031302
return NotImplemented
13041303
return <logic to compare two {class_name} instances>
1305-
""".format(
1306-
class_name=class_name
1307-
)
1308-
)
1304+
""".format(class_name=class_name))
13091305

13101306
def return_type_incompatible_with_supertype(
13111307
self,
@@ -1802,7 +1798,7 @@ def redundant_cast(self, typ: Type, context: Context) -> None:
18021798
)
18031799

18041800
def assert_type_fail(self, source_type: Type, target_type: Type, context: Context) -> None:
1805-
(source, target) = format_type_distinctly(source_type, target_type, options=self.options)
1801+
source, target = format_type_distinctly(source_type, target_type, options=self.options)
18061802
self.fail(f"Expression is of type {source}, not {target}", context, code=codes.ASSERT_TYPE)
18071803

18081804
def unimported_type_becomes_any(self, prefix: str, typ: Type, ctx: Context) -> None:

mypy/report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def _report_any_exprs(self) -> None:
285285
column_names = ["Name", "Anys", "Exprs", "Coverage"]
286286
rows: list[list[str]] = []
287287
for filename in sorted(self.counts):
288-
(num_any, num_total) = self.counts[filename]
288+
num_any, num_total = self.counts[filename]
289289
coverage = (float(num_total - num_any) / float(num_total)) * 100
290290
coverage_str = f"{coverage:.2f}%"
291291
rows.append([filename, str(num_any), str(num_total), coverage_str])

mypy/semanal_typeddict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def analyze_typeddict_classdef(self, defn: ClassDef) -> tuple[bool, TypeInfo | N
162162
self.add_keys_and_types_from_base(
163163
base, field_types, required_keys, readonly_keys, defn
164164
)
165-
(new_field_types, new_statements, new_required_keys, new_readonly_keys) = (
165+
new_field_types, new_statements, new_required_keys, new_readonly_keys = (
166166
self.analyze_typeddict_classdef_fields(defn, oldfields=field_types)
167167
)
168168
if new_field_types is None:

mypy/test/meta/test_parse_data.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,24 @@ def _run_pytest(data_suite: str) -> PytestResult:
1414
class ParseTestDataSuite(Suite):
1515
def test_parse_invalid_case(self) -> None:
1616
# Act
17-
result = _run_pytest(
18-
"""
17+
result = _run_pytest("""
1918
[case abc]
2019
s: str
2120
[case foo-XFAIL]
2221
s: str
23-
"""
24-
)
22+
""")
2523

2624
# Assert
2725
assert "Invalid testcase id 'foo-XFAIL'" in result.stdout
2826

2927
def test_parse_invalid_section(self) -> None:
3028
# Act
31-
result = _run_pytest(
32-
"""
29+
result = _run_pytest("""
3330
[case abc]
3431
s: str
3532
[unknownsection]
3633
abc
37-
"""
38-
)
34+
""")
3935

4036
# Assert
4137
expected_lineno = result.input.splitlines().index("[unknownsection]") + 1
@@ -46,14 +42,12 @@ def test_parse_invalid_section(self) -> None:
4642

4743
def test_bad_ge_version_check(self) -> None:
4844
# Act
49-
actual = _run_pytest(
50-
"""
45+
actual = _run_pytest("""
5146
[case abc]
5247
s: str
5348
[out version>=3.10]
5449
abc
55-
"""
56-
)
50+
""")
5751

5852
# Assert
5953
assert (
@@ -62,14 +56,12 @@ def test_bad_ge_version_check(self) -> None:
6256

6357
def test_bad_eq_version_check(self) -> None:
6458
# Act
65-
actual = _run_pytest(
66-
"""
59+
actual = _run_pytest("""
6760
[case abc]
6861
s: str
6962
[out version==3.7]
7063
abc
71-
"""
72-
)
64+
""")
7365

7466
# Assert
7567
assert (

0 commit comments

Comments
 (0)