Skip to content

Commit 3a3d03c

Browse files
committed
format
1 parent ec5c0cc commit 3a3d03c

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

src/sphinx_codeautolink/extension/block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from __future__ import annotations
44

55
import re
6+
from collections.abc import Callable
67
from copy import copy
78
from dataclasses import dataclass
89
from pathlib import Path
9-
from typing import Callable
1010

1111
from bs4 import BeautifulSoup
1212
from docutils import nodes
@@ -263,7 +263,7 @@ def _format_source_for_error(
263263
guides[ix] = "block source:"
264264
pad = max(len(i) + 1 for i in guides)
265265
guides = [g.ljust(pad) for g in guides]
266-
return "\n".join([g + s for g, s in zip(guides, lines)])
266+
return "\n".join([g + s for g, s in zip(guides, lines, strict=True)])
267267

268268
def _parsing_error_msg(self, error: Exception, language: str, source: str) -> str:
269269
return "\n".join(

src/sphinx_codeautolink/extension/directive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,5 @@ def unknown_visit(self, node) -> None:
136136
if isinstance(node, DeferredExamples):
137137
# Remove surrounding paragraph too
138138
node.parent.parent.remove(node.parent)
139-
if isinstance(node, (ConcatMarker, PrefaceMarker, SkipMarker)):
139+
if isinstance(node, ConcatMarker | PrefaceMarker | SkipMarker):
140140
node.parent.remove(node)

src/sphinx_codeautolink/extension/resolve.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
from __future__ import annotations
44

5+
from collections.abc import Callable
56
from contextlib import suppress
67
from dataclasses import dataclass
78
from functools import cache
89
from importlib import import_module
910
from inspect import isclass, isroutine
1011
from types import UnionType
11-
from typing import Any, Callable, Union, get_type_hints
12+
from typing import Any, Union, get_type_hints
1213

1314
from sphinx_codeautolink.parse import Name, NameBreak
1415

src/sphinx_codeautolink/parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def visit_Import(self, node: ast.Import | ast.ImportFrom, prefix: str = "") -> N
432432
if prefix:
433433
self.save_access(Access(LinkContext.import_from, [], prefix_components))
434434

435-
for import_name, alias in zip(import_names, aliases):
435+
for import_name, alias in zip(import_names, aliases, strict=True):
436436
if not import_star:
437437
components = [
438438
Component(n, *linenos(node), "load") for n in import_name.split(".")
@@ -561,7 +561,7 @@ def visit_MatchClass(self, node: ast.AST) -> None:
561561
accesses.append(access)
562562

563563
assigns = []
564-
for attr, pattern in zip(node.kwd_attrs, node.kwd_patterns):
564+
for attr, pattern in zip(node.kwd_attrs, node.kwd_patterns, strict=True):
565565
target = self.visit(pattern)
566566
attr_comps = [
567567
Component(NameBreak.call, *linenos(node), "load"),

tests/extension/src/test_project/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Docstring."""
22

3-
from typing import Optional, Union
4-
53
from .sub import SubBar, subfoo # noqa: F401
64

75

@@ -31,15 +29,15 @@ def bar() -> Foo:
3129
"""Bar test function."""
3230

3331

34-
def optional() -> Optional[Foo]:
32+
def optional() -> Foo | None:
3533
"""Return optional type."""
3634

3735

38-
def optional_manual() -> Union[None, Foo]:
36+
def optional_manual() -> None | Foo:
3937
"""Return manually constructed optional type."""
4038

4139

42-
def optional_counter() -> Union[Foo, Baz]:
40+
def optional_counter() -> Foo | Baz:
4341
"""Failing case for incorrect optional type handling."""
4442

4543

tests/parse/_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def wrapper(self):
2626
print(f"components={components}, code_str={code_str}")
2727
print("\nParsed names:")
2828
[print(n) for n in names]
29-
for n, e in zip(names, expected):
29+
for n, e in zip(names, expected, strict=True):
3030
s = ".".join(c for c in n.import_components)
3131
assert s == e[0], f"Wrong import! Expected\n{e}\ngot\n{n}"
3232
assert n.code_str == e[1], f"Wrong code str! Expected\n{e}\ngot\n{n}"

0 commit comments

Comments
 (0)