Skip to content

Commit 8a54ff4

Browse files
committed
Code formatting via ruff
1 parent 941518e commit 8a54ff4

14 files changed

Lines changed: 36 additions & 34 deletions

File tree

src/docbuild/cli/cmd_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def cli(
9393

9494
if ctx.invoked_subcommand is None:
9595
# If no subcommand is invoked, show the help message
96-
click.echo(10* '-')
96+
click.echo(10 * '-')
9797
click.echo(ctx.get_help())
9898
ctx.exit(0)
9999

src/docbuild/models/deliverable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def branch(self) -> str:
111111
# If we cannot find the branch in the current language node,
112112
# we look in the English language and use this branch
113113
node = self._node.getparent().xpath(
114-
"ancestor::builddocs/language"
114+
'ancestor::builddocs/language'
115115
"[@lang!='en-us' or @default!='1' or @default!='true']/branch",
116116
)
117117
if node:

src/docbuild/utils/contextmgr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Provides context managers."""
22

3-
43
from collections.abc import Callable, Generator
54
from contextlib import contextmanager
65
from dataclasses import dataclass
@@ -14,7 +13,7 @@ class TimerData:
1413
name: str
1514
start: float = float('nan')
1615
end: float = float('nan')
17-
elapsed: float = float("nan")
16+
elapsed: float = float('nan')
1817

1918

2019
def make_timer(

src/docbuild/utils/decorators.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
if TYPE_CHECKING:
1111
from ..config.xml.checks import CheckResult
1212

13-
F = TypeVar(
14-
'F',
15-
bound=Callable[[etree._Element | etree._ElementTree], 'CheckResult']
16-
)
13+
F = TypeVar('F', bound=Callable[[etree._Element | etree._ElementTree], 'CheckResult'])
1714
"""Type variable for functions that take an XML element or tree and return CheckResult."""
1815

1916

src/docbuild/utils/doc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" """
2+
23
from collections.abc import Callable
34
import functools
45
from typing import Any, ParamSpec, TypeVar
@@ -18,7 +19,8 @@ def __missing__(self, key: str) -> str:
1819

1920

2021
def docstring(
21-
template: str | None = None, **kwargs: Any # noqa: ANN401
22+
template: str | None = None,
23+
**kwargs: Any, # noqa: ANN401
2224
) -> Callable[[Callable[P, R]], Callable[P, R]]:
2325
"""Replace placeholders in docstring.
2426
@@ -49,8 +51,9 @@ def greet():
4951
print(greet.__doc__)
5052
# Output: "Hello Alice, welcome to {place}"
5153
"""
54+
5255
def decorator(func: Callable[P, R]) -> Callable[P, R]:
53-
base_template = template if template is not None else func.__doc__ or ""
56+
base_template = template if template is not None else func.__doc__ or ''
5457
formatted_doc = base_template.format_map(SafeDict(kwargs))
5558

5659
@functools.wraps(func)

tests/cli/config/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def test_showconfig_help_option(runner):
55
result = runner.invoke(cli, ['config', '--help'])
6-
print(result.output)
6+
# print(result.output)
77
assert result.exit_code == 0
88
assert 'Commands:' in result.output
99
assert 'env' in result.output

tests/cli/test_cmd_build.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def mock_from_str(s: str):
164164

165165
# Patch necessary methods
166166
monkeypatch.setattr(callback_module, 'ValidationError', MockValidationError)
167-
monkeypatch.setattr(callback_module.Doctype, 'from_str', staticmethod(mock_from_str))
167+
monkeypatch.setattr(
168+
callback_module.Doctype, 'from_str', staticmethod(mock_from_str)
169+
)
168170
monkeypatch.setattr(
169171
callback_module.Doctype,
170172
'model_fields',

tests/config/xml/test_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ def assert_results(string, messages: list[str]) -> None:
102102
# -----------------------
103103
def test_check_in_registry():
104104
"""Test that the check functions are registered correctly."""
105-
print(">>>", register_check.registry)
106105
assert len(register_check.registry) > 0, 'No checks registered'
107106
for func in register_check.registry:
108107
assert callable(func), f'{func.__name__} is not callable'
109-
assert func.__name__.startswith('check_'), \
108+
assert func.__name__.startswith('check_'), (
110109
f'{func.__name__} does not start with "check_"'
110+
)
111111

112112

113113
# ----

tests/config/xml/test_stitch.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ def test_load_check_functions_returns_list(self):
2323
assert func.__name__.startswith('check_')
2424

2525

26-
2726
class TestCreateStitchfile:
28-
@pytest.mark.skip("TODO")
27+
@pytest.mark.skip('TODO')
2928
def test_create_stitchfile_with_xml_files(self, tmp_path):
3029
"""Test create_stitchfile with XML files in directory."""
3130
# This will cover lines 52-58

tests/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,17 @@ def make_path_mock(**members: Any | Callable[[], Any]) -> MagicMock:
132132

133133
return mock
134134

135+
135136
def make_path_mock(
136-
path: str = "",
137+
path: str = '',
137138
return_values: dict = None,
138139
side_effects: dict = None,
139140
attributes: dict = None,
140141
) -> MagicMock:
141142
from pathlib import Path
142143
from unittest.mock import MagicMock
143144

144-
path_obj = Path(path) if path else Path("mocked")
145+
path_obj = Path(path) if path else Path('mocked')
145146
mock = MagicMock(spec=Path)
146147

147148
# Path-like behavior
@@ -150,9 +151,9 @@ def make_path_mock(
150151
mock.name = path_obj.name
151152
mock.suffix = path_obj.suffix
152153
mock.parts = path_obj.parts
153-
mock.parent = make_path_mock(
154-
str(path_obj.parent)
155-
) if path_obj != path_obj.parent else mock
154+
mock.parent = (
155+
make_path_mock(str(path_obj.parent)) if path_obj != path_obj.parent else mock
156+
)
156157

157158
# / operator
158159
def truediv(other: str) -> MagicMock:
@@ -180,7 +181,6 @@ def truediv(other: str) -> MagicMock:
180181
return mock
181182

182183

183-
184184
@pytest.fixture
185185
def fake_envfile(
186186
monkeypatch: pytest.MonkeyPatch,

0 commit comments

Comments
 (0)