Skip to content

Commit adc533a

Browse files
committed
make formats
1 parent d652bdd commit adc533a

File tree

18 files changed

+67
-133
lines changed

18 files changed

+67
-133
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ jobs:
7171
- os: macos
7272
target: aarch64
7373
interpreter: 3.9 3.10 3.11 3.12 3.13 pypy3.8 pypy3.9 pypy3.10
74-
75-
74+
75+
7676

7777
runs-on: ${{ matrix.os }}-latest
7878
steps:

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: pip install pre-commit
2626
- name: "Install Rust toolchain"
2727
run: rustup component add rustfmt clippy
28-
- run: pre-commit run --all-files
28+
- run: make lint
2929

3030
Tests:
3131
name: ${{ matrix.os }} / ${{ matrix.python-version }}

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ dev:
2323

2424
lint:
2525
poetry run mypy
26+
pre-commit run --all-files
2627

2728
test:
2829
PENDULUM_EXTENSIONS=0 poetry run pytest -q tests
29-
poetry run pytest -q tests
30+
poetry run pytest -q tests

clock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ translations = {{}}
190190
def format_dict(self, d, tab=1):
191191
s = ["{\n"]
192192
for k, v in d.items():
193-
if isinstance(v, (dict, LocaleDataDict)):
194-
v = self.format_dict(v, tab + 1)
195-
else:
196-
v = repr(v)
193+
v = (
194+
self.format_dict(v, tab + 1)
195+
if isinstance(v, (dict, LocaleDataDict))
196+
else repr(v)
197+
)
197198

198199
s.append(f"{' ' * tab}{k!r}: {v},\n")
199200
s.append(f'{" " * (tab - 1)}}}')

poetry.lock

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

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ ruff = "^0.7.3"
8080

8181
[tool.poetry.group.build.dependencies]
8282
maturin = ">=1.0,<2.0"
83-
patchelf = ">=0.17"
8483

8584
[tool.poetry.extras]
8685
test = ["time-machine"]
@@ -95,7 +94,7 @@ unfixable = [
9594
"ERA", # do not autoremove commented out code
9695
]
9796
target-version = "py39"
98-
line-length = 88
97+
line-length = 100
9998
extend-select = [
10099
"B", # flake8-bugbear
101100
"C4", # flake8-comprehensions

src/pendulum/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,18 @@
5959

6060

6161
@overload
62-
def timezone(name: int) -> FixedTimezone: ...
62+
def timezone(name: int) -> FixedTimezone:
63+
...
6364

6465

6566
@overload
66-
def timezone(name: str) -> Timezone: ...
67+
def timezone(name: str) -> Timezone:
68+
...
6769

6870

6971
@overload
70-
def timezone(name: str | int) -> Timezone | FixedTimezone: ...
72+
def timezone(name: str | int) -> Timezone | FixedTimezone:
73+
...
7174

7275

7376
def timezone(name: str | int) -> Timezone | FixedTimezone:
@@ -202,21 +205,24 @@ def time(hour: int, minute: int = 0, second: int = 0, microsecond: int = 0) -> T
202205
def instance(
203206
obj: _datetime.datetime,
204207
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
205-
) -> DateTime: ...
208+
) -> DateTime:
209+
...
206210

207211

208212
@overload
209213
def instance(
210214
obj: _datetime.date,
211215
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
212-
) -> Date: ...
216+
) -> Date:
217+
...
213218

214219

215220
@overload
216221
def instance(
217222
obj: _datetime.time,
218223
tz: str | Timezone | FixedTimezone | _datetime.tzinfo | None = UTC,
219-
) -> Time: ...
224+
) -> Time:
225+
...
220226

221227

222228
def instance(

src/pendulum/date.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,12 @@ def __add__(self, other: timedelta) -> Self:
257257
return self._add_timedelta(other)
258258

259259
@overload # type: ignore[override] # this is only needed because of Python 3.7
260-
def __sub__(self, __delta: timedelta) -> Self: ...
260+
def __sub__(self, __delta: timedelta) -> Self:
261+
...
261262

262263
@overload
263-
def __sub__(self, __dt: datetime) -> NoReturn: ...
264+
def __sub__(self, __dt: datetime) -> NoReturn:
265+
...
264266

265267
@overload
266268
def __sub__(self, __dt: Self) -> Interval[Date]:

src/pendulum/datetime.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ def instance(
146146

147147
@overload
148148
@classmethod
149-
def now(cls, tz: datetime.tzinfo | None = None) -> Self: ...
149+
def now(cls, tz: datetime.tzinfo | None = None) -> Self:
150+
...
150151

151152
@overload
152153
@classmethod
153-
def now(cls, tz: str | Timezone | FixedTimezone | None = None) -> Self: ...
154+
def now(cls, tz: str | Timezone | FixedTimezone | None = None) -> Self:
155+
...
154156

155157
@classmethod
156158
def now(
@@ -1184,7 +1186,8 @@ def average( # type: ignore[override]
11841186
)
11851187

11861188
@overload # type: ignore[override]
1187-
def __sub__(self, other: datetime.timedelta) -> Self: ...
1189+
def __sub__(self, other: datetime.timedelta) -> Self:
1190+
...
11881191

11891192
@overload
11901193
def __sub__(self, other: DateTime) -> Interval[datetime.datetime]:

src/pendulum/duration.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,12 @@ def __mul__(self, other: int | float) -> Self:
375375
__rmul__ = __mul__
376376

377377
@overload
378-
def __floordiv__(self, other: timedelta) -> int: ...
378+
def __floordiv__(self, other: timedelta) -> int:
379+
...
379380

380381
@overload
381-
def __floordiv__(self, other: int) -> Self: ...
382+
def __floordiv__(self, other: int) -> Self:
383+
...
382384

383385
def __floordiv__(self, other: int | timedelta) -> int | Duration:
384386
if not isinstance(other, (int, timedelta)):
@@ -401,10 +403,12 @@ def __floordiv__(self, other: int | timedelta) -> int | Duration:
401403
)
402404

403405
@overload
404-
def __truediv__(self, other: timedelta) -> float: ...
406+
def __truediv__(self, other: timedelta) -> float:
407+
...
405408

406409
@overload
407-
def __truediv__(self, other: float) -> Self: ...
410+
def __truediv__(self, other: float) -> Self:
411+
...
408412

409413
def __truediv__(self, other: int | float | timedelta) -> Self | float:
410414
if not isinstance(other, (int, float, timedelta)):

src/pendulum/formatting/formatter.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,9 @@ def _check_parsed(
440440
# we use it and don't go any further
441441
if parsed["timestamp"] is not None:
442442
str_us = str(parsed["timestamp"])
443-
if "." in str_us:
444-
microseconds = int(f'{str_us.split(".")[1].ljust(6, "0")}')
445-
else:
446-
microseconds = 0
443+
microseconds = (
444+
int(f"{str_us.split('.')[1].ljust(6, '0')}") if "." in str_us else 0
445+
)
447446

448447
from pendulum.helpers import local_time
449448

src/pendulum/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def add_duration(
6262
minutes: int = 0,
6363
seconds: float = 0,
6464
microseconds: int = 0,
65-
) -> _DT: ...
65+
) -> _DT:
66+
...
6667

6768

6869
@overload

src/pendulum/interval.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,25 @@ def __mul__(self, other: int | float) -> Duration: # type: ignore[override]
336336
__rmul__ = __mul__ # type: ignore[assignment]
337337

338338
@overload # type: ignore[override]
339-
def __floordiv__(self, other: timedelta) -> int: ...
339+
def __floordiv__(self, other: timedelta) -> int:
340+
...
340341

341342
@overload
342-
def __floordiv__(self, other: int) -> Duration: ...
343+
def __floordiv__(self, other: int) -> Duration:
344+
...
343345

344346
def __floordiv__(self, other: int | timedelta) -> int | Duration:
345347
return self.as_duration().__floordiv__(other)
346348

347349
__div__ = __floordiv__ # type: ignore[assignment]
348350

349351
@overload # type: ignore[override]
350-
def __truediv__(self, other: timedelta) -> float: ...
352+
def __truediv__(self, other: timedelta) -> float:
353+
...
351354

352355
@overload
353-
def __truediv__(self, other: float) -> Duration: ...
356+
def __truediv__(self, other: float) -> Duration:
357+
...
354358

355359
def __truediv__(self, other: float | timedelta) -> Duration | float:
356360
return self.as_duration().__truediv__(other)

src/pendulum/parsing/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
" )"
4545
")?"
4646
# Time (optional) # noqa: ERA001
47-
"(?P<time>"
48-
r" (?P<timesep>\ )?" # Separator (space)
47+
"(?P<time>" r" (?P<timesep>\ )?" # Separator (space)
4948
# HH:mm:ss (optional mm and ss)
5049
r" (?P<hour>\d{1,2}):(?P<minute>\d{1,2})?(?::(?P<second>\d{1,2}))?"
5150
# Subsecond part (optional)

src/pendulum/parsing/iso8601.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
" )"
4343
")?"
4444
# Time (optional) # noqa: ERA001
45-
"(?P<time>"
46-
r" (?P<timesep>[T\ ])?" # Separator (T or space)
45+
"(?P<time>" r" (?P<timesep>[T\ ])?" # Separator (T or space)
4746
# HH:mm:ss (optional mm and ss)
4847
r" (?P<hour>\d{1,2})(?P<minsep>:)?(?P<minute>\d{1,2})?(?P<secsep>:)?(?P<second>\d{1,2})?"
4948
# Subsecond part (optional)

src/pendulum/testing/traveller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def __exit__(
4747
exc_type: type[BaseException] | None,
4848
exc_val: BaseException | None,
4949
exc_tb: TracebackType,
50-
) -> None: ...
50+
) -> None:
51+
...
5152

5253
def _not_implemented(self) -> NotImplementedError:
5354
return NotImplementedError()

src/pendulum/time.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ def __add__(self, other: datetime.timedelta) -> Time:
168168
return self.add_timedelta(other)
169169

170170
@overload
171-
def __sub__(self, other: time) -> pendulum.Duration: ...
171+
def __sub__(self, other: time) -> pendulum.Duration:
172+
...
172173

173174
@overload
174-
def __sub__(self, other: datetime.timedelta) -> Time: ...
175+
def __sub__(self, other: datetime.timedelta) -> Time:
176+
...
175177

176178
def __sub__(self, other: time | datetime.timedelta) -> pendulum.Duration | Time:
177179
if not isinstance(other, (Time, time, timedelta)):
@@ -191,10 +193,12 @@ def __sub__(self, other: time | datetime.timedelta) -> pendulum.Duration | Time:
191193
return other.diff(self, False)
192194

193195
@overload
194-
def __rsub__(self, other: time) -> pendulum.Duration: ...
196+
def __rsub__(self, other: time) -> pendulum.Duration:
197+
...
195198

196199
@overload
197-
def __rsub__(self, other: datetime.timedelta) -> Time: ...
200+
def __rsub__(self, other: datetime.timedelta) -> Time:
201+
...
198202

199203
def __rsub__(self, other: time | datetime.timedelta) -> pendulum.Duration | Time:
200204
if not isinstance(other, (Time, time)):

0 commit comments

Comments
 (0)