Skip to content

Commit 969129d

Browse files
Евгений БлиновЕвгений Блинов
authored andcommitted
Remove .ruff.toml and refactor imports to use consistent typing and
formatting
1 parent 4e88a4b commit 969129d

8 files changed

Lines changed: 47 additions & 41 deletions

File tree

.ruff.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

displayhooks/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
from displayhooks.converter import converted_displayhook as converted_displayhook # noqa: F401
2-
from displayhooks.autorestore import autorestore_displayhook as autorestore_displayhook # noqa: F401
3-
from displayhooks.not_display import not_display as not_display # noqa: F401
1+
from displayhooks.autorestore import (
2+
autorestore_displayhook as autorestore_displayhook,
3+
)
4+
from displayhooks.converter import (
5+
converted_displayhook as converted_displayhook,
6+
)
7+
from displayhooks.not_display import not_display as not_display

displayhooks/autorestore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
else:
66
from typing_extensions import ParamSpec # pragma: no cover
77

8-
from typing import TypeVar, Callable
98
from functools import wraps
10-
9+
from typing import Callable, TypeVar
1110

1211
FunctionParameters = ParamSpec('FunctionParameters')
1312
ReturningValue = TypeVar('ReturningValue')

displayhooks/converter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import sys
2-
from typing import Callable, Any
3-
from threading import Lock
42
from functools import wraps
5-
3+
from threading import Lock
4+
from typing import Any, Callable
65

76
lock = Lock()
87

displayhooks/not_display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Type, Any
1+
from typing import Any, Type
22

33
from displayhooks.converter import converted_displayhook
44

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ keywords = [
4646
paths_to_mutate="displayhooks"
4747
runner="pytest"
4848

49+
[tool.ruff]
50+
lint.ignore = ['E501', 'E712', 'PTH123', 'PTH118', 'PLR2004', 'PTH107', 'SIM105', 'SIM102', 'RET503', 'PLR0912', 'C901']
51+
lint.select = ["ERA001", "YTT", "ASYNC", "BLE", "B", "A", "COM", "INP", "PIE", "T20", "PT", "RSE", "RET", "SIM", "SLOT", "TID252", "ARG", "PTH", "I", "C90", "N", "E", "W", "D201", "D202", "D419", "F", "PL", "PLE", "PLR", "PLW", "RUF", "TRY201", "TRY400", "TRY401"]
52+
format.quote-style = "single"
53+
4954
[project.urls]
5055
'Source' = 'https://github.com/pomponchik/displayhooks'
5156
'Tracker' = 'https://github.com/pomponchik/displayhooks/issues'

tests/test_converter.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
import pytest
77

8-
from displayhooks import converted_displayhook, autorestore_displayhook
8+
from displayhooks import autorestore_displayhook, converted_displayhook
99

1010

1111
@pytest.mark.parametrize(
12-
['value'],
12+
'value',
1313
[
14-
('kek',),
15-
('lol',),
16-
(1,),
17-
(1.5,),
14+
'kek',
15+
'lol',
16+
1,
17+
1.5,
1818
],
1919
)
2020
@autorestore_displayhook
@@ -29,7 +29,7 @@ def new_displayhook(value: Any) -> Any:
2929

3030
output = buffer.getvalue()
3131

32-
assert output == f'{repr(value)}\n'
32+
assert output == f'{value!r}\n'
3333

3434

3535
@autorestore_displayhook
@@ -48,18 +48,18 @@ def new_displayhook(value: Any) -> Any:
4848

4949

5050
@pytest.mark.parametrize(
51-
['value'],
51+
'value',
5252
[
53-
('kek',),
54-
('lol',),
55-
(1,),
56-
(1.5,),
53+
'kek',
54+
'lol',
55+
1,
56+
1.5,
5757
],
5858
)
5959
@autorestore_displayhook
6060
def test_elliminating_convertion(value):
6161
@converted_displayhook
62-
def new_displayhook(value: Any) -> Any:
62+
def new_displayhook(value: Any) -> Any: # noqa: ARG001
6363
return None
6464

6565
buffer = io.StringIO()
@@ -74,7 +74,7 @@ def new_displayhook(value: Any) -> Any:
7474
@autorestore_displayhook
7575
def test_elliminating_convertion_with_none():
7676
@converted_displayhook
77-
def new_displayhook(value: Any) -> Any:
77+
def new_displayhook(value: Any) -> Any: # noqa: ARG001
7878
return None
7979

8080
buffer = io.StringIO()
@@ -87,18 +87,18 @@ def new_displayhook(value: Any) -> Any:
8787

8888

8989
@pytest.mark.parametrize(
90-
['value'],
90+
'value',
9191
[
92-
('kek',),
93-
('lol',),
94-
(1,),
95-
(1.5,),
92+
'kek',
93+
'lol',
94+
1,
95+
1.5,
9696
],
9797
)
9898
@autorestore_displayhook
9999
def test_real_convertion(value):
100100
@converted_displayhook
101-
def new_displayhook(value: Any) -> Any:
101+
def new_displayhook(value: Any) -> Any: # noqa: ARG001
102102
return 'cheburek'
103103

104104
buffer = io.StringIO()
@@ -107,4 +107,4 @@ def new_displayhook(value: Any) -> Any:
107107

108108
output = buffer.getvalue()
109109

110-
assert output == f'{repr("cheburek")}\n'
110+
assert output == f'{"cheburek"!r}\n'

tests/test_not_display.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from displayhooks import not_display, autorestore_displayhook
7+
from displayhooks import autorestore_displayhook, not_display
88

99

1010
@autorestore_displayhook
@@ -19,21 +19,21 @@ def display_something(something):
1919
return buffer.getvalue()
2020

2121
assert display_something(5) == ''
22-
assert display_something('kek') == f'{repr("kek")}\n'
22+
assert display_something('kek') == f'{"kek"!r}\n'
2323

2424

2525
@pytest.mark.parametrize(
26-
['callable'],
26+
'some_callable',
2727
[
28-
(lambda: not_display(int, float),),
29-
(lambda: [not_display(int), not_display(float)],), # type: ignore[func-returns-value]
30-
(lambda: not_display(float, int),),
31-
(lambda: [not_display(float), not_display(int)],), # type: ignore[func-returns-value]
28+
lambda: not_display(int, float),
29+
lambda: [not_display(int), not_display(float)], # type: ignore[func-returns-value]
30+
lambda: not_display(float, int),
31+
lambda: [not_display(float), not_display(int)], # type: ignore[func-returns-value]
3232
],
3333
)
3434
@autorestore_displayhook
35-
def test_not_display_ints_and_floats(callable):
36-
callable()
35+
def test_not_display_ints_and_floats(some_callable):
36+
some_callable()
3737

3838
def display_something(something):
3939
buffer = io.StringIO()
@@ -44,4 +44,4 @@ def display_something(something):
4444

4545
assert display_something(5) == ''
4646
assert display_something(5.5) == ''
47-
assert display_something('kek') == f'{repr("kek")}\n'
47+
assert display_something('kek') == f'{"kek"!r}\n'

0 commit comments

Comments
 (0)