Skip to content

Commit 0140e13

Browse files
committed
Lint
1 parent 80ff719 commit 0140e13

12 files changed

+65
-53
lines changed

formate/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def version_callback(ctx: click.Context, param: click.Option, value: int) -> Non
8787
)
8888
@click.argument("filename", type=click.STRING, nargs=-1)
8989
@click_command()
90-
def main( # noqa: PRM002
90+
def main(
9191
filename: Iterable[PathLike],
9292
config_file: PathLike,
9393
exclude: "Optional[List[str]]",

formate/dynamic_quotes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646

4747
__all__ = ("dynamic_quotes", )
4848

49-
if sys.version_info >= (3, 12):
49+
if sys.version_info >= (3, 12): # pragma: no cover (<py312)
5050
StrOrConstant = ast.Constant
51-
else:
51+
else: # pragma: no cover (py312+)
5252
StrOrConstant = Union[ast.Str, ast.Constant]
5353

5454

formate/ellipses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def rewrite_ellipsis(
8080
if not node.body[0].value.value is Ellipsis:
8181
return
8282

83-
elif sys.version_info >= (3, 8): # pragma: no cover (<py38)
83+
elif sys.version_info >= (3, 8): # pragma: no cover (<py38 OR py312+)
8484
if not isinstance(node.body[0].value, (ast.Constant, ast.Ellipsis)):
8585
return
8686

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
'8',
2424
marks=pytest.mark.skipif(_click_major != 8, reason="Output differs on click 8"),
2525
),
26-
]
26+
],
2727
)
2828
def test_help(
2929
advanced_file_regression: AdvancedFileRegressionFixture,

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_parse_hooks():
2020
"collections-import-rewrite": 20,
2121
"noqa-reformat": 60,
2222
"ellipsis-reformat": 70,
23-
"isort": {"priority": 50, "kwargs": isort_kwargs}
23+
"isort": {"priority": 50, "kwargs": isort_kwargs},
2424
},
2525
"config": global_config,
2626
}

tests/test_dynamic_quotes.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def foo():
5353
(value_2, value_2),
5454
('assert t.uname == "\\xe4\\xf6\\xfc"', 'assert t.uname == "äöü"'),
5555
('assert t.uname == "\\udce4\\udcf6\\udcfc"', 'assert t.uname == "\\udce4\\udcf6\\udcfc"'),
56-
]
56+
],
5757
)
5858
def test_quotes(value: str, expects: str):
5959
assert dynamic_quotes(value) == expects
@@ -79,21 +79,21 @@ def test_quotes(value: str, expects: str):
7979
("def foo():\n\t'docstring'\n\t'hello\\nworld'", "def foo():\n\t'docstring'\n\t'hello\\nworld'"),
8080
(
8181
'def foo():\n\t\'docstring\'\n\t"hello\\nworld"',
82-
'def foo():\n\t\'docstring\'\n\t"hello\\nworld"'
82+
'def foo():\n\t\'docstring\'\n\t"hello\\nworld"',
8383
),
8484
('def foo():\n\t\'docstring\'\n\t"\\""', "def foo():\n\t'docstring'\n\t'\"'"),
8585
('def foo():\n\t\'docstring\'\n\t"quote \\""', "def foo():\n\t'docstring'\n\t'quote \"'"),
8686
("def foo():\n\t'docstring'\n\t'\\''", "def foo():\n\t'docstring'\n\t\"'\""),
8787
("def foo():\n\t'docstring'\n\t'quote \\''", "def foo():\n\t'docstring'\n\t\"quote '\""),
8888
(
8989
'def foo():\n\t\'docstring\'\n\tassert t.uname == "\\xe4\\xf6\\xfc"',
90-
'def foo():\n\t\'docstring\'\n\tassert t.uname == "äöü"'
90+
'def foo():\n\t\'docstring\'\n\tassert t.uname == "äöü"',
9191
),
9292
(
9393
'def foo():\n\t\'docstring\'\n\tassert t.uname == "\\udce4\\udcf6\\udcfc"',
94-
'def foo():\n\t\'docstring\'\n\tassert t.uname == "\\udce4\\udcf6\\udcfc"'
94+
'def foo():\n\t\'docstring\'\n\tassert t.uname == "\\udce4\\udcf6\\udcfc"',
9595
),
96-
]
96+
],
9797
)
9898
def test_quotes_function(value: str, expects: str):
9999
assert dynamic_quotes(value) == expects
@@ -104,7 +104,7 @@ def test_quotes_function(value: str, expects: str):
104104
[
105105
(
106106
"async def foo():\n\t'docstring'\n\t'hello world'",
107-
'async def foo():\n\t\'docstring\'\n\t"hello world"'
107+
'async def foo():\n\t\'docstring\'\n\t"hello world"',
108108
),
109109
("async def foo():\n\t'docstring'\n\t''", "async def foo():\n\t'docstring'\n\t''"),
110110
('async def foo():\n\t\'docstring\'\n\t""', "async def foo():\n\t'docstring'\n\t''"),
@@ -119,39 +119,39 @@ def test_quotes_function(value: str, expects: str):
119119
('async def foo():\n\t\'docstring\'\n\t"☃"', "async def foo():\n\t'docstring'\n\t'☃'"),
120120
(
121121
'async def foo():\n\t\'docstring\'\n\tprint(123)\n"☃"',
122-
"async def foo():\n\t'docstring'\n\tprint(123)\n'☃'"
122+
"async def foo():\n\t'docstring'\n\tprint(123)\n'☃'",
123123
),
124124
(
125125
'async def foo():\n\t\'docstring\'\n\t"☃"\nprint(123)',
126-
"async def foo():\n\t'docstring'\n\t'☃'\nprint(123)"
126+
"async def foo():\n\t'docstring'\n\t'☃'\nprint(123)",
127127
),
128128
(
129129
"async def foo():\n\t'docstring'\n\t'hello\\nworld'",
130-
"async def foo():\n\t'docstring'\n\t'hello\\nworld'"
130+
"async def foo():\n\t'docstring'\n\t'hello\\nworld'",
131131
),
132132
(
133133
'async def foo():\n\t\'docstring\'\n\t"hello\\nworld"',
134-
'async def foo():\n\t\'docstring\'\n\t"hello\\nworld"'
134+
'async def foo():\n\t\'docstring\'\n\t"hello\\nworld"',
135135
),
136136
('async def foo():\n\t\'docstring\'\n\t"\\""', "async def foo():\n\t'docstring'\n\t'\"'"),
137137
(
138138
'async def foo():\n\t\'docstring\'\n\t"quote \\""',
139-
"async def foo():\n\t'docstring'\n\t'quote \"'"
139+
"async def foo():\n\t'docstring'\n\t'quote \"'",
140140
),
141141
("async def foo():\n\t'docstring'\n\t'\\''", "async def foo():\n\t'docstring'\n\t\"'\""),
142142
(
143143
"async def foo():\n\t'docstring'\n\t'quote \\''",
144-
"async def foo():\n\t'docstring'\n\t\"quote '\""
144+
"async def foo():\n\t'docstring'\n\t\"quote '\"",
145145
),
146146
(
147147
'async def foo():\n\t\'docstring\'\n\tassert t.uname == "\\xe4\\xf6\\xfc"',
148-
'async def foo():\n\t\'docstring\'\n\tassert t.uname == "äöü"'
148+
'async def foo():\n\t\'docstring\'\n\tassert t.uname == "äöü"',
149149
),
150150
(
151151
'async def foo():\n\t\'docstring\'\n\tassert t.uname == "\\udce4\\udcf6\\udcfc"',
152-
'async def foo():\n\t\'docstring\'\n\tassert t.uname == "\\udce4\\udcf6\\udcfc"'
152+
'async def foo():\n\t\'docstring\'\n\tassert t.uname == "\\udce4\\udcf6\\udcfc"',
153153
),
154-
]
154+
],
155155
)
156156
def test_quotes_async_function(value: str, expects: str):
157157
assert dynamic_quotes(value) == expects

tests/test_ellipses.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async def foo(): ...
112112
pytest.param(
113113
function_with_docstring_containing_stub,
114114
function_with_docstring_containing_stub,
115-
id="function_with_docstring_containing_stub"
115+
id="function_with_docstring_containing_stub",
116116
),
117117
pytest.param(function_with_body, function_with_body, id="function_with_body"),
118118
pytest.param(function_with_ellipsis, function_with_ellipsis_inline, id="function_with_ellipsis"),
@@ -130,17 +130,19 @@ async def foo(): ...
130130
pytest.param(
131131
async_function_with_ellipsis,
132132
async_function_with_ellipsis_inline,
133-
id="async_function_with_ellipsis"
133+
id="async_function_with_ellipsis",
134134
),
135135
pytest.param(
136136
async_function_with_ellipsis_inline,
137137
async_function_with_ellipsis_inline,
138-
id="async_function_with_ellipsis_inline"
138+
id="async_function_with_ellipsis_inline",
139139
),
140140
pytest.param(
141-
function_with_body_int, function_with_body_int, id="async_function_with_ellipsis_inline"
141+
function_with_body_int,
142+
function_with_body_int,
143+
id="async_function_with_ellipsis_inline",
142144
),
143-
]
145+
],
144146
)
145147
def test_ellipsis_reformat(code: str, expected: str):
146148
assert ellipsis_reformat(code) == expected

tests/test_entry_points.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_entry_points():
2424
"collections-import-rewrite",
2525
"isort",
2626
"yapf",
27-
}, hook_names
27+
}, hook_names
2828

2929

3030
def test_entry_points_file(advanced_data_regression: AdvancedDataRegressionFixture):

tests/test_imports.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,30 @@ def foo():
4444
pytest.param(multiple_mixed_imports_spaced_out, id="multiple_mixed_imports_spaced_out"),
4545
pytest.param(
4646
"# code.py\n__all__ = ['foo', 'bar']\n\nfrom collections import (\nIterable,\nCounter,\n)",
47-
id="top_level_code_before"
47+
id="top_level_code_before",
4848
),
4949
pytest.param(
5050
"from collections import (\nIterable,\nCounter,\n)\nfrom .. import bar\nfrom . import baz\n",
51-
id="top_level_relative"
51+
id="top_level_relative",
5252
),
5353
pytest.param("class F:\n\tfrom collections import (\nIterable,\nCounter,\n)", id="in_class_tabs"),
5454
pytest.param(
55-
"def foo():\n\tfrom collections import (\nIterable,\nCounter,\n)", id="in_function_tabs"
55+
"def foo():\n\tfrom collections import (\nIterable,\nCounter,\n)",
56+
id="in_function_tabs",
5657
),
5758
pytest.param(
58-
"class F:\n from collections import (\nIterable,\nCounter,\n)", id="in_class_spaces"
59+
"class F:\n from collections import (\nIterable,\nCounter,\n)",
60+
id="in_class_spaces",
5961
),
6062
pytest.param(
6163
"def foo():\n from collections import (\nIterable,\nCounter,\n)",
62-
id="in_function_spaces"
64+
id="in_function_spaces",
6365
),
6466
pytest.param(
6567
"def foo():\n from collections import (\nIterable,\nCounter,\n)\n from typing import List",
66-
id="in_function_another_import"
68+
id="in_function_another_import",
6769
),
68-
]
70+
],
6971
)
7072

7173

tests/test_mini_hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def next(self): ...
237237
class DivergedBranches(Error): ...
238238
def check_diverged(repo: Repo, current_sha: Any, new_sha: Any) -> None: ...
239239
240-
'''
240+
''',
241241
)
242242

243243
advanced_file_regression.check(squish_stubs(source, "file.pyi"), extension="._py_")

0 commit comments

Comments
 (0)