Skip to content

Commit ad9aab4

Browse files
committed
Revert whitespace changes
1 parent 5efce7b commit ad9aab4

13 files changed

+84
-77
lines changed

scripts/check_for_inconsistent_pandas_namespace.py

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

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

3637

scripts/check_test_naming.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
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-
1211
from __future__ import annotations
1312

1413
import argparse

scripts/generate_pip_deps_from_conda.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
generated with this script:
1313
$ python scripts/generate_pip_deps_from_conda.py --compare
1414
"""
15-
1615
import argparse
1716
import pathlib
1817
import re

scripts/pandas_errors_documented.py

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

1211
import argparse

scripts/sort_whatsnew_note.py

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

2928
import argparse

scripts/tests/test_check_test_naming.py

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

scripts/tests/test_inconsistent_namespace_check.py

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

77
BAD_FILE_0 = (
8-
"from pandas import Categorical\ncat_0 = Categorical()\ncat_1 = pd.Categorical()"
8+
"from pandas import Categorical\n"
9+
"cat_0 = Categorical()\n"
10+
"cat_1 = pd.Categorical()"
911
)
1012
BAD_FILE_1 = (
11-
"from pandas import Categorical\ncat_0 = pd.Categorical()\ncat_1 = Categorical()"
13+
"from pandas import Categorical\n"
14+
"cat_0 = pd.Categorical()\n"
15+
"cat_1 = Categorical()"
1216
)
1317
BAD_FILE_2 = (
1418
"from pandas import Categorical\n"

scripts/tests/test_validate_docstrings.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def redundant_import(self, paramx=None, paramy=None) -> None:
3434
--------
3535
>>> import numpy as np
3636
>>> import pandas as pd
37-
>>> df = pd.DataFrame(np.ones((3, 3)), columns=("a", "b", "c"))
37+
>>> df = pd.DataFrame(np.ones((3, 3)),
38+
... columns=('a', 'b', 'c'))
3839
>>> df.all(axis=1)
3940
0 True
4041
1 True
@@ -49,14 +50,14 @@ def unused_import(self) -> None:
4950
Examples
5051
--------
5152
>>> import pandas as pdf
52-
>>> df = pd.DataFrame(np.ones((3, 3)), columns=("a", "b", "c"))
53+
>>> df = pd.DataFrame(np.ones((3, 3)), columns=('a', 'b', 'c'))
5354
"""
5455

5556
def missing_whitespace_around_arithmetic_operator(self) -> None:
5657
"""
5758
Examples
5859
--------
59-
>>> 2 + 5
60+
>>> 2+5
6061
7
6162
"""
6263

@@ -65,14 +66,14 @@ def indentation_is_not_a_multiple_of_four(self) -> None:
6566
Examples
6667
--------
6768
>>> if 2 + 5:
68-
... pass
69+
... pass
6970
"""
7071

7172
def missing_whitespace_after_comma(self) -> None:
7273
"""
7374
Examples
7475
--------
75-
>>> df = pd.DataFrame(np.ones((3, 3)), columns=("a", "b", "c"))
76+
>>> df = pd.DataFrame(np.ones((3,3)),columns=('a','b', 'c'))
7677
"""
7778

7879
def write_array_like_with_hyphen_not_underscore(self) -> None:
@@ -226,13 +227,13 @@ def test_validate_all_ignore_errors(self, monkeypatch):
226227
"errors": [
227228
("ER01", "err desc"),
228229
("ER02", "err desc"),
229-
("ER03", "err desc"),
230+
("ER03", "err desc")
230231
],
231232
"warnings": [],
232233
"examples_errors": "",
233234
"deprecated": True,
234235
"file": "file1",
235-
"file_line": "file_line1",
236+
"file_line": "file_line1"
236237
},
237238
)
238239
monkeypatch.setattr(
@@ -271,13 +272,14 @@ def test_validate_all_ignore_errors(self, monkeypatch):
271272
None: {"ER03"},
272273
"pandas.DataFrame.align": {"ER01"},
273274
# ignoring an error that is not requested should be of no effect
274-
"pandas.Index.all": {"ER03"},
275-
},
275+
"pandas.Index.all": {"ER03"}
276+
}
276277
)
277278
# two functions * two not global ignored errors - one function ignored error
278279
assert exit_status == 2 * 2 - 1
279280

280281

282+
281283
class TestApiItems:
282284
@property
283285
def api_doc(self):

scripts/validate_docstrings.py

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

1918
import argparse
@@ -70,10 +69,8 @@
7069
}
7170
ALL_ERRORS = set(NUMPYDOC_ERROR_MSGS).union(set(ERROR_MSGS))
7271
duplicated_errors = set(NUMPYDOC_ERROR_MSGS).intersection(set(ERROR_MSGS))
73-
assert not duplicated_errors, (
74-
f"Errors {duplicated_errors} exist in both pandas "
75-
"and numpydoc, should they be removed from pandas?"
76-
)
72+
assert not duplicated_errors, (f"Errors {duplicated_errors} exist in both pandas "
73+
"and numpydoc, should they be removed from pandas?")
7774

7875

7976
def pandas_error(code, **kwargs):
@@ -260,7 +257,7 @@ def pandas_validate(func_name: str):
260257
pandas_error(
261258
"SA05",
262259
reference_name=rel_name,
263-
right_reference=rel_name[len("pandas.") :],
260+
right_reference=rel_name[len("pandas."):],
264261
)
265262
for rel_name in doc.see_also
266263
if rel_name.startswith("pandas.")
@@ -368,18 +365,17 @@ def print_validate_all_results(
368365
for func_name, res in result.items():
369366
error_messages = dict(res["errors"])
370367
actual_failures = set(error_messages)
371-
expected_failures = ignore_errors.get(func_name, set()) | ignore_errors.get(
372-
None, set()
373-
)
368+
expected_failures = (ignore_errors.get(func_name, set())
369+
| ignore_errors.get(None, set()))
374370
for err_code in actual_failures - expected_failures:
375371
sys.stdout.write(
376-
f"{prefix}{res['file']}:{res['file_line']}:"
377-
f"{err_code}:{func_name}:{error_messages[err_code]}\n"
372+
f'{prefix}{res["file"]}:{res["file_line"]}:'
373+
f'{err_code}:{func_name}:{error_messages[err_code]}\n'
378374
)
379375
exit_status += 1
380376
for err_code in ignore_errors.get(func_name, set()) - actual_failures:
381377
sys.stdout.write(
382-
f"{prefix}{res['file']}:{res['file_line']}:"
378+
f'{prefix}{res["file"]}:{res["file_line"]}:'
383379
f"{err_code}:{func_name}:"
384380
"EXPECTED TO FAIL, BUT NOT FAILING\n"
385381
)
@@ -388,9 +384,8 @@ def print_validate_all_results(
388384
return exit_status
389385

390386

391-
def print_validate_one_results(
392-
func_name: str, ignore_errors: dict[str, set[str]]
393-
) -> int:
387+
def print_validate_one_results(func_name: str,
388+
ignore_errors: dict[str, set[str]]) -> int:
394389
def header(title, width=80, char="#") -> str:
395390
full_line = char * width
396391
side_len = (width - len(title) - 2) // 2
@@ -401,18 +396,15 @@ def header(title, width=80, char="#") -> str:
401396

402397
result = pandas_validate(func_name)
403398

404-
result["errors"] = [
405-
(code, message)
406-
for code, message in result["errors"]
407-
if code not in ignore_errors.get(None, set())
408-
]
399+
result["errors"] = [(code, message) for code, message in result["errors"]
400+
if code not in ignore_errors.get(None, set())]
409401

410402
sys.stderr.write(header(f"Docstring ({func_name})"))
411403
sys.stderr.write(f"{result['docstring']}\n")
412404

413405
sys.stderr.write(header("Validation"))
414406
if result["errors"]:
415-
sys.stderr.write(f"{len(result['errors'])} Errors found for `{func_name}`:\n")
407+
sys.stderr.write(f'{len(result["errors"])} Errors found for `{func_name}`:\n')
416408
for err_code, err_desc in result["errors"]:
417409
sys.stderr.write(f"\t{err_code}\t{err_desc}\n")
418410
else:
@@ -439,16 +431,14 @@ def _format_ignore_errors(raw_ignore_errors):
439431
raise ValueError(
440432
f"Object `{obj_name}` is present in more than one "
441433
"--ignore_errors argument. Please use it once and specify "
442-
"the errors separated by commas."
443-
)
434+
"the errors separated by commas.")
444435
ignore_errors[obj_name] = set(error_codes.split(","))
445436

446437
unknown_errors = ignore_errors[obj_name] - ALL_ERRORS
447438
if unknown_errors:
448439
raise ValueError(
449440
f"Object `{obj_name}` is ignoring errors {unknown_errors} "
450-
f"which are not known. Known errors are: {ALL_ERRORS}"
451-
)
441+
f"which are not known. Known errors are: {ALL_ERRORS}")
452442

453443
# global errors "PR02,ES01"
454444
else:
@@ -458,19 +448,27 @@ def _format_ignore_errors(raw_ignore_errors):
458448
if unknown_errors:
459449
raise ValueError(
460450
f"Unknown errors {unknown_errors} specified using --ignore_errors "
461-
"Known errors are: {ALL_ERRORS}"
462-
)
451+
"Known errors are: {ALL_ERRORS}")
463452

464453
return ignore_errors
465454

466455

467-
def main(func_name, output_format, prefix, ignore_deprecated, ignore_errors):
456+
def main(
457+
func_name,
458+
output_format,
459+
prefix,
460+
ignore_deprecated,
461+
ignore_errors
462+
):
468463
"""
469464
Main entry point. Call the validation for one or for all docstrings.
470465
"""
471466
if func_name is None:
472467
return print_validate_all_results(
473-
output_format, prefix, ignore_deprecated, ignore_errors
468+
output_format,
469+
prefix,
470+
ignore_deprecated,
471+
ignore_errors
474472
)
475473
else:
476474
return print_validate_one_results(func_name, ignore_errors)
@@ -526,11 +524,10 @@ def main(func_name, output_format, prefix, ignore_deprecated, ignore_errors):
526524
args = argparser.parse_args(sys.argv[1:])
527525

528526
sys.exit(
529-
main(
530-
args.function,
531-
args.format,
532-
args.prefix,
533-
args.ignore_deprecated,
534-
_format_ignore_errors(args.ignore_errors),
535-
)
527+
main(args.function,
528+
args.format,
529+
args.prefix,
530+
args.ignore_deprecated,
531+
_format_ignore_errors(args.ignore_errors),
532+
)
536533
)

scripts/validate_exception_location.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
As a pre-commit hook:
1919
pre-commit run validate-errors-locations --all-files
2020
"""
21-
2221
from __future__ import annotations
2322

2423
import argparse

0 commit comments

Comments
 (0)