Skip to content

Commit df3d335

Browse files
committed
autoformat with ruff
1 parent 11892cd commit df3d335

9 files changed

Lines changed: 20 additions & 26 deletions

File tree

benchmarks/comparison/perf_charts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
# Font/SVG helpers (shared with charts.py)
3636
# ---------------------------------------------------------------------------
3737

38-
_SYSTEM_FONT = (
39-
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif"
40-
)
38+
_SYSTEM_FONT = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif"
4139

4240
_SVG_RC = {
4341
"svg.fonttype": "none",
@@ -315,11 +313,13 @@ def main() -> None:
315313
for mod in IMPORT_MODULES:
316314
t = measure_import(mod, python=python)
317315
times_ns[mod] = t
318-
print(f" {mod:25s}: {t/1e6:.2f} ms")
316+
print(f" {mod:25s}: {t / 1e6:.2f} ms")
319317

320318
print("\nGenerating import-time charts…")
321319
for theme in ("light", "dark"):
322-
plot_import_time(times_ns, out_dir / f"import-time-{theme}.svg", theme)
320+
plot_import_time(
321+
times_ns, out_dir / f"import-time-{theme}.svg", theme
322+
)
323323

324324
# -- Package size --
325325
print("\nGenerating package-size charts…")

pysrc/whenever/_deltas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ def _check_bound(i: int | None, max_value: int) -> int | None:
197197

198198

199199
def _check_component(
200-
value: int, sign: Sign, max_value: int # may also be UNSET
200+
value: int,
201+
sign: Sign,
202+
max_value: int, # may also be UNSET
201203
) -> tuple[int | None, Sign]:
202204
if value is UNSET:
203205
return None, sign
@@ -444,7 +446,6 @@ def keys(self) -> KeysView:
444446
# documented here for the API docs.
445447
if not TYPE_CHECKING: # pragma: no cover
446448
if SPHINX_RUNNING:
447-
448449
# FUTURE: an optimized ValuesView class that defers to the internal
449450
# fields directly instead of going through __getitem__
450451
def values(self) -> ValuesView[int]:
@@ -1621,7 +1622,6 @@ def parse_iso(cls, s: str, /) -> ItemizedDateDelta:
16211622
# documented here for the API docs.
16221623
if not TYPE_CHECKING: # pragma: no cover
16231624
if SPHINX_RUNNING:
1624-
16251625
# FUTURE: an optimized ValuesView class that defers to the internal
16261626
# fields directly instead of going through __getitem__
16271627
def values(self) -> ValuesView[int]:

pysrc/whenever/_pywhenever.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ def _start_of_dt(dt: _datetime, unit: str) -> _datetime:
230230
return dt
231231
elif unit == "week":
232232
raise ValueError(
233-
"unit 'week' is ambiguous. "
234-
"Use 'week_mon' or 'week_sun' instead."
233+
"unit 'week' is ambiguous. Use 'week_mon' or 'week_sun' instead."
235234
)
236235
else:
237236
raise ValueError(
@@ -268,8 +267,7 @@ def _end_of_dt(dt: _datetime, unit: str) -> _datetime:
268267
return dt
269268
elif unit == "week":
270269
raise ValueError(
271-
"unit 'week' is ambiguous. "
272-
"Use 'week_mon' or 'week_sun' instead."
270+
"unit 'week' is ambiguous. Use 'week_mon' or 'week_sun' instead."
273271
)
274272
else:
275273
raise ValueError(
@@ -7051,9 +7049,7 @@ def _unpatch_time() -> None:
70517049
_member = globals()[_name]
70527050
if isinstance(_member, (type, _ftype)) and (
70537051
getattr(_member, "__module__", "") or ""
7054-
).startswith(
7055-
"whenever"
7056-
): # pragma: no branch
7052+
).startswith("whenever"): # pragma: no branch
70577053
_member.__module__ = "whenever"
70587054

70597055
# disable further subclassing

tests/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"--P2D",
2424
"++P2D",
2525
"1P2",
26-
f"P{MAX_I64+2}Y",
27-
f"P-{MAX_I64+2}Y",
26+
f"P{MAX_I64 + 2}Y",
27+
f"P-{MAX_I64 + 2}Y",
2828
"P3R", # invalid unit
2929
"PT3M", # time component
3030
"P3.4Y", # decimal

tests/test_date.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from typing import Literal
77

88
import pytest
9-
109
from whenever import (
1110
Date,
1211
IsoWeekDate,
@@ -18,8 +17,6 @@
1817
YearMonth,
1918
)
2019

21-
from tests.test_date_delta import make_ddelta
22-
2320
from .common import (
2421
AlwaysEqual,
2522
AlwaysLarger,

tests/test_misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def test_extension_doesnt_import_tz_modules():
9595
check=True,
9696
)
9797
imported = json.loads(result.stdout)
98-
assert (
99-
imported == []
100-
), f"unexpected modules imported on 'import whenever': {imported}"
98+
assert imported == [], (
99+
f"unexpected modules imported on 'import whenever': {imported}"
100+
)
101101

102102

103103
@pytest.mark.skipif(

tests/test_offset_datetime.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,9 @@ def test_offset_preserved(self):
25082508
@suppress(StaleOffsetWarning)
25092509
def test_invalid_unit(self):
25102510
with pytest.raises(ValueError, match="Invalid (unit|value for unit)"):
2511-
OffsetDateTime(2024, 8, 15, 14, 30, offset=hours(5)).end_of("invalid") # type: ignore[arg-type]
2511+
OffsetDateTime(2024, 8, 15, 14, 30, offset=hours(5)).end_of(
2512+
"invalid"
2513+
) # type: ignore[arg-type]
25122514

25132515
@suppress(StaleOffsetWarning)
25142516
def test_week_value_error(self):

tests/test_plain_datetime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ def test_until_in_units(self):
753753

754754

755755
class TestShiftOperators:
756-
757756
def test_timedelta(self):
758757
d = PlainDateTime(2020, 8, 15, 23, 12, 9, nanosecond=987_654)
759758
with suppress(NaiveArithmeticWarning):

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)