Skip to content

Commit 28c72f1

Browse files
committed
CLN: Apply ruff format to scripts/
1 parent 2891172 commit 28c72f1

14 files changed

+51
-61
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ repos:
3232
exclude: ^pandas/tests
3333
args: [--select, "ANN001,ANN2", --fix-only, --exit-non-zero-on-fix]
3434
- id: ruff-format
35-
exclude: ^scripts|^pandas/tests/frame/test_query_eval.py
35+
exclude: ^pandas/tests/frame/test_query_eval.py
3636
- repo: https://github.com/jendrikseipp/vulture
3737
rev: v2.14
3838
hooks:

scripts/check_for_inconsistent_pandas_namespace.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
from typing import NamedTuple
3131

3232
ERROR_MESSAGE = (
33-
"{path}:{lineno}:{col_offset}: "
34-
"Found both '{prefix}.{name}' and '{name}' in {path}"
33+
"{path}:{lineno}:{col_offset}: Found both '{prefix}.{name}' and '{name}' in {path}"
3534
)
3635

3736

scripts/check_test_naming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
NOTE: if this finds a false positive, you can add the comment `# not a test` to the
99
class or function definition. Though hopefully that shouldn't be necessary.
1010
"""
11+
1112
from __future__ import annotations
1213

1314
import argparse

scripts/generate_pip_deps_from_conda.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
generated with this script:
1313
$ python scripts/generate_pip_deps_from_conda.py --compare
1414
"""
15+
1516
import argparse
1617
import pathlib
1718
import re

scripts/pandas_errors_documented.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
pre-commit run pandas-errors-documented --all-files
88
"""
9+
910
from __future__ import annotations
1011

1112
import argparse

scripts/sort_whatsnew_note.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
2424
pre-commit run sort-whatsnew-items --all-files
2525
"""
26+
2627
from __future__ import annotations
2728

2829
import argparse

scripts/tests/test_check_test_naming.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
0,
2525
),
2626
(
27-
"class Foo: # not a test\n"
28-
" pass\n"
29-
"def test_foo():\n"
30-
" Class.foo()\n",
27+
"class Foo: # not a test\n pass\ndef test_foo():\n Class.foo()\n",
3128
"",
3229
0,
3330
),

scripts/tests/test_inconsistent_namespace_check.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
)
66

77
BAD_FILE_0 = (
8-
"from pandas import Categorical\n"
9-
"cat_0 = Categorical()\n"
10-
"cat_1 = pd.Categorical()"
8+
"from pandas import Categorical\ncat_0 = Categorical()\ncat_1 = pd.Categorical()"
119
)
1210
BAD_FILE_1 = (
13-
"from pandas import Categorical\n"
14-
"cat_0 = pd.Categorical()\n"
15-
"cat_1 = Categorical()"
11+
"from pandas import Categorical\ncat_0 = pd.Categorical()\ncat_1 = Categorical()"
1612
)
1713
BAD_FILE_2 = (
1814
"from pandas import Categorical\n"

scripts/tests/test_validate_docstrings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from scripts import validate_docstrings
77

88

9+
# fmt: off
910
class BadDocstrings:
1011
"""Everything here has a bad docstring"""
1112

@@ -88,6 +89,7 @@ def leftover_files(self) -> None:
8889
>>> import pathlib
8990
>>> pathlib.Path("foo.txt").touch()
9091
"""
92+
# fmt: on
9193

9294

9395
class TestValidator:
@@ -227,13 +229,13 @@ def test_validate_all_ignore_errors(self, monkeypatch):
227229
"errors": [
228230
("ER01", "err desc"),
229231
("ER02", "err desc"),
230-
("ER03", "err desc")
232+
("ER03", "err desc"),
231233
],
232234
"warnings": [],
233235
"examples_errors": "",
234236
"deprecated": True,
235237
"file": "file1",
236-
"file_line": "file_line1"
238+
"file_line": "file_line1",
237239
},
238240
)
239241
monkeypatch.setattr(
@@ -272,14 +274,13 @@ def test_validate_all_ignore_errors(self, monkeypatch):
272274
None: {"ER03"},
273275
"pandas.DataFrame.align": {"ER01"},
274276
# ignoring an error that is not requested should be of no effect
275-
"pandas.Index.all": {"ER03"}
276-
}
277+
"pandas.Index.all": {"ER03"},
278+
},
277279
)
278280
# two functions * two not global ignored errors - one function ignored error
279281
assert exit_status == 2 * 2 - 1
280282

281283

282-
283284
class TestApiItems:
284285
@property
285286
def api_doc(self):

scripts/validate_docstrings.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
$ ./validate_docstrings.py
1414
$ ./validate_docstrings.py pandas.DataFrame.head
1515
"""
16+
1617
from __future__ import annotations
1718

1819
import argparse
@@ -380,13 +381,13 @@ def print_validate_all_results(
380381
)
381382
for err_code in actual_failures - expected_failures:
382383
sys.stdout.write(
383-
f'{prefix}{res["file"]}:{res["file_line"]}:'
384+
f"{prefix}{res['file']}:{res['file_line']}:"
384385
f"{err_code}:{func_name}:{error_messages[err_code]}\n"
385386
)
386387
exit_status += 1
387388
for err_code in ignore_errors.get(func_name, set()) - actual_failures:
388389
sys.stdout.write(
389-
f'{prefix}{res["file"]}:{res["file_line"]}:'
390+
f"{prefix}{res['file']}:{res['file_line']}:"
390391
f"{err_code}:{func_name}:"
391392
"EXPECTED TO FAIL, BUT NOT FAILING\n"
392393
)
@@ -419,7 +420,7 @@ def header(title, width=80, char="#") -> str:
419420

420421
sys.stderr.write(header("Validation"))
421422
if result["errors"]:
422-
sys.stderr.write(f'{len(result["errors"])} Errors found for `{func_name}`:\n')
423+
sys.stderr.write(f"{len(result['errors'])} Errors found for `{func_name}`:\n")
423424
for err_code, err_desc in result["errors"]:
424425
sys.stderr.write(f"\t{err_code}\t{err_desc}\n")
425426
else:

0 commit comments

Comments
 (0)