Skip to content

Commit 3940aac

Browse files
committed
ruff formatting
1 parent 8fc4ffa commit 3940aac

14 files changed

Lines changed: 62 additions & 40 deletions

File tree

_python_utils_tests/test_decorators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def some_annotated_classmethod(cls, arg: int) -> int:
5454
def test_wraps_classmethod() -> None:
5555
some_class = SomeClass()
5656
some_class.some_classmethod = MagicMock() # type: ignore[method-assign]
57-
wrapped_method = wraps_classmethod(
58-
SomeClass.some_classmethod
59-
)(
57+
wrapped_method = wraps_classmethod(SomeClass.some_classmethod)(
6058
some_class.some_classmethod
6159
)
6260
wrapped_method(123)

_python_utils_tests/test_time.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ async def generator_clean() -> types.AsyncGenerator[int, None]:
157157

158158

159159
@pytest.mark.asyncio
160-
async def test_aio_generator_timeout_detector_decorator_reraise_total() -> None:
160+
async def test_aio_generator_timeout_detector_decorator_reraise_total() -> (
161+
None
162+
):
161163
# Test total timeout with reraise
162164
@python_utils.aio_generator_timeout_detector_decorator(total_timeout=0.1)
163165
async def generator_reraise() -> types.AsyncGenerator[int, None]:

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
documentation root, use os.path.abspath to make it absolute, like shown here.
1313
#
1414
"""
15+
1516
import os
1617
import sys
1718
from datetime import date

python_utils/aio.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ async def acontainer(
6262
types.AsyncIterable[_T],
6363
types.Callable[..., types.AsyncIterable[_T]],
6464
],
65-
container: types.Callable[[types.Iterable[_T]], types.Collection[_T]] =
66-
list,
65+
container: types.Callable[
66+
[types.Iterable[_T]], types.Collection[_T]
67+
] = list,
6768
) -> types.Collection[_T]:
6869
"""
6970
Asyncio version of list()/set()/tuple()/etc() using an async for loop.

python_utils/converters.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1024.
1313
- remap: Remap a value from one range to another.
1414
"""
15+
1516
# Ignoring all mypy errors because mypy doesn't understand many modern typing
1617
# constructs... please, use pyright instead if you can.
1718
from __future__ import annotations
@@ -284,41 +285,41 @@ def scale_1024(
284285

285286
@typing.overload
286287
def remap(
287-
value: decimal.Decimal,
288-
old_min: decimal.Decimal | float,
289-
old_max: decimal.Decimal | float,
290-
new_min: decimal.Decimal | float,
291-
new_max: decimal.Decimal | float,
288+
value: decimal.Decimal,
289+
old_min: decimal.Decimal | float,
290+
old_max: decimal.Decimal | float,
291+
new_min: decimal.Decimal | float,
292+
new_max: decimal.Decimal | float,
292293
) -> decimal.Decimal: ...
293294

294295

295296
@typing.overload
296297
def remap(
297-
value: decimal.Decimal| float,
298-
old_min: decimal.Decimal,
299-
old_max: decimal.Decimal| float,
300-
new_min: decimal.Decimal| float,
301-
new_max: decimal.Decimal| float,
298+
value: decimal.Decimal | float,
299+
old_min: decimal.Decimal,
300+
old_max: decimal.Decimal | float,
301+
new_min: decimal.Decimal | float,
302+
new_max: decimal.Decimal | float,
302303
) -> decimal.Decimal: ...
303304

304305

305306
@typing.overload
306307
def remap(
307-
value: decimal.Decimal | float,
308-
old_min: decimal.Decimal | float,
309-
old_max: decimal.Decimal,
310-
new_min: decimal.Decimal | float,
311-
new_max: decimal.Decimal | float,
308+
value: decimal.Decimal | float,
309+
old_min: decimal.Decimal | float,
310+
old_max: decimal.Decimal,
311+
new_min: decimal.Decimal | float,
312+
new_max: decimal.Decimal | float,
312313
) -> decimal.Decimal: ...
313314

314315

315316
@typing.overload
316317
def remap(
317-
value: decimal.Decimal | float,
318-
old_min: decimal.Decimal | float,
319-
old_max: decimal.Decimal | float,
320-
new_min: decimal.Decimal,
321-
new_max: decimal.Decimal | float,
318+
value: decimal.Decimal | float,
319+
old_min: decimal.Decimal | float,
320+
old_max: decimal.Decimal | float,
321+
new_min: decimal.Decimal,
322+
new_max: decimal.Decimal | float,
322323
) -> decimal.Decimal: ...
323324

324325

@@ -459,10 +460,10 @@ def remap( # pyright: ignore[reportInconsistentOverload]
459460
new_value = (value - old_min) * new_range # type: ignore[operator] # pyright: ignore[reportOperatorIssue, reportUnknownVariableType]
460461

461462
if type_ is int:
462-
new_value //= old_range # pyright: ignore[reportUnknownVariableType]
463+
new_value //= old_range # pyright: ignore[reportUnknownVariableType]
463464
else:
464-
new_value /= old_range # pyright: ignore[reportUnknownVariableType]
465+
new_value /= old_range # pyright: ignore[reportUnknownVariableType]
465466

466-
new_value += new_min # type: ignore[operator] # pyright: ignore[reportOperatorIssue, reportUnknownVariableType]
467+
new_value += new_min # type: ignore[operator] # pyright: ignore[reportOperatorIssue, reportUnknownVariableType]
467468

468469
return types.cast(_TN, new_value)

python_utils/decorators.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Each decorator is designed to enhance the functionality of Python
1414
functions and methods in a simple and reusable manner.
1515
"""
16+
1617
import contextlib
1718
import functools
1819
import logging
@@ -60,8 +61,9 @@ def _set_attributes(
6061

6162

6263
def listify(
63-
collection: types.Callable[[types.Iterable[_T]], types.Collection[_T]] =
64-
list,
64+
collection: types.Callable[
65+
[types.Iterable[_T]], types.Collection[_T]
66+
] = list,
6567
allow_empty: bool = True,
6668
) -> types.Callable[
6769
[types.Callable[..., types.Optional[types.Iterable[_T]]]],
@@ -116,8 +118,9 @@ def listify(
116118
def _listify(
117119
function: types.Callable[..., types.Optional[types.Iterable[_T]]],
118120
) -> types.Callable[..., types.Collection[_T]]:
119-
def __listify(*args: types.Any, **kwargs: types.Any) \
120-
-> types.Collection[_T]:
121+
def __listify(
122+
*args: types.Any, **kwargs: types.Any
123+
) -> types.Collection[_T]:
121124
result: types.Optional[types.Iterable[_T]] = function(
122125
*args, **kwargs
123126
)
@@ -137,7 +140,9 @@ def __listify(*args: types.Any, **kwargs: types.Any) \
137140
return _listify
138141

139142

140-
def sample(sample_rate: float) -> types.Callable[
143+
def sample(
144+
sample_rate: float,
145+
) -> types.Callable[
141146
[types.Callable[_P, _T]],
142147
types.Callable[_P, types.Optional[_T]],
143148
]:

python_utils/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
reraise(*args, **kwargs):
1010
Reraises the current exception.
1111
"""
12+
1213
from . import types
1314

1415

python_utils/formatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
default: str = 'just now') -> str:
1414
Returns string representing 'time since' e.g. 3 days ago, 5 hours ago.
1515
"""
16+
1617
# pyright: reportUnnecessaryIsInstance=false
1718
import datetime
1819

python_utils/generators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
batcher(iterable, batch_size=10):
1111
Generator wrapper that returns items with a given batch size.
1212
"""
13+
1314
import asyncio
1415
import time
1516

python_utils/import_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Imports the requested items into the global scope, with support for
1212
relative imports and custom exception handling.
1313
"""
14+
1415
from . import types
1516

1617

0 commit comments

Comments
 (0)