Skip to content

Commit d004398

Browse files
committed
Remove old flake8 validation
1 parent d5baf82 commit d004398

File tree

5 files changed

+0
-192
lines changed

5 files changed

+0
-192
lines changed

ci/code_checks.sh

-65
Original file line numberDiff line numberDiff line change
@@ -69,71 +69,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6969
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX02,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
7070
RET=$(($RET + $?)) ; echo $MSG "DONE"
7171

72-
MSG='Partially validate docstrings (EX03)' ; echo $MSG
73-
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \
74-
pandas.Series.plot.line \
75-
pandas.Series.to_sql \
76-
pandas.Series.to_latex \
77-
pandas.errors.DatabaseError \
78-
pandas.errors.IndexingError \
79-
pandas.errors.InvalidColumnName \
80-
pandas.errors.PossibleDataLossError \
81-
pandas.errors.PossiblePrecisionLoss \
82-
pandas.errors.SettingWithCopyError \
83-
pandas.errors.SettingWithCopyWarning \
84-
pandas.errors.SpecificationError \
85-
pandas.errors.UndefinedVariableError \
86-
pandas.errors.ValueLabelTypeMismatch \
87-
pandas.Timestamp.ceil \
88-
pandas.Timestamp.floor \
89-
pandas.Timestamp.round \
90-
pandas.read_pickle \
91-
pandas.ExcelWriter \
92-
pandas.read_json \
93-
pandas.io.json.build_table_schema \
94-
pandas.DataFrame.to_latex \
95-
pandas.io.formats.style.Styler.to_latex \
96-
pandas.read_parquet \
97-
pandas.DataFrame.to_sql \
98-
pandas.read_stata \
99-
pandas.core.resample.Resampler.pipe \
100-
pandas.core.resample.Resampler.interpolate \
101-
pandas.plotting.scatter_matrix \
102-
pandas.pivot \
103-
pandas.merge_asof \
104-
pandas.wide_to_long \
105-
pandas.Index.rename \
106-
pandas.Index.droplevel \
107-
pandas.Index.isin \
108-
pandas.MultiIndex.names \
109-
pandas.MultiIndex.droplevel \
110-
pandas.IndexSlice \
111-
pandas.Grouper \
112-
pandas.io.formats.style.Styler.map \
113-
pandas.io.formats.style.Styler.apply_index \
114-
pandas.io.formats.style.Styler.map_index \
115-
pandas.io.formats.style.Styler.format \
116-
pandas.io.formats.style.Styler.format_index \
117-
pandas.io.formats.style.Styler.relabel_index \
118-
pandas.io.formats.style.Styler.hide \
119-
pandas.io.formats.style.Styler.set_td_classes \
120-
pandas.io.formats.style.Styler.set_tooltips \
121-
pandas.io.formats.style.Styler.set_uuid \
122-
pandas.io.formats.style.Styler.pipe \
123-
pandas.io.formats.style.Styler.highlight_between \
124-
pandas.io.formats.style.Styler.highlight_quantile \
125-
pandas.io.formats.style.Styler.background_gradient \
126-
pandas.io.formats.style.Styler.text_gradient \
127-
pandas.DataFrame.values \
128-
pandas.DataFrame.groupby \
129-
pandas.DataFrame.idxmax \
130-
pandas.DataFrame.idxmin \
131-
pandas.DataFrame.pivot \
132-
pandas.DataFrame.sort_values \
133-
pandas.DataFrame.plot.hexbin \
134-
pandas.DataFrame.plot.line \
135-
RET=$(($RET + $?)) ; echo $MSG "DONE"
136-
13772
fi
13873

13974
### DOCUMENTATION NOTEBOOKS ###

environment.yml

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ dependencies:
7575
- cxx-compiler
7676

7777
# code checks
78-
- flake8=6.1.0 # run in subprocess over docstring examples
7978
- mypy=1.8.0 # pre-commit uses locally installed mypy
8079
- tokenize-rt # scripts/check_for_inconsistent_pandas_namespace.py
8180
- pre-commit>=3.6.0

requirements-dev.txt

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ seaborn
5252
moto
5353
flask
5454
asv>=0.6.1
55-
flake8==6.1.0
5655
mypy==1.8.0
5756
tokenize-rt
5857
pre-commit>=3.6.0

scripts/tests/test_validate_docstrings.py

-62
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,6 @@ def redundant_import(self, paramx=None, paramy=None) -> None:
4444
Series([], dtype: bool)
4545
"""
4646

47-
def unused_import(self) -> None:
48-
"""
49-
Examples
50-
--------
51-
>>> import pandas as pdf
52-
>>> df = pd.DataFrame(np.ones((3, 3)), columns=("a", "b", "c"))
53-
"""
54-
55-
def missing_whitespace_around_arithmetic_operator(self) -> None:
56-
"""
57-
Examples
58-
--------
59-
>>> 2 + 5
60-
7
61-
"""
62-
63-
def indentation_is_not_a_multiple_of_four(self) -> None:
64-
"""
65-
Examples
66-
--------
67-
>>> if 2 + 5:
68-
... pass
69-
"""
70-
71-
def missing_whitespace_after_comma(self) -> None:
72-
"""
73-
Examples
74-
--------
75-
>>> df = pd.DataFrame(np.ones((3, 3)), columns=("a", "b", "c"))
76-
"""
77-
7847
def write_array_like_with_hyphen_not_underscore(self) -> None:
7948
"""
8049
In docstrings, use array-like over array_like
@@ -153,37 +122,6 @@ def test_bad_class(self, capsys) -> None:
153122
"redundant_import",
154123
("Do not import pandas, as it is imported automatically",),
155124
),
156-
(
157-
"BadDocstrings",
158-
"unused_import",
159-
(
160-
"flake8 error: line 1, col 1: F401 'pandas as pdf' "
161-
"imported but unused",
162-
),
163-
),
164-
(
165-
"BadDocstrings",
166-
"missing_whitespace_around_arithmetic_operator",
167-
(
168-
"flake8 error: line 1, col 2: "
169-
"E226 missing whitespace around arithmetic operator",
170-
),
171-
),
172-
(
173-
"BadDocstrings",
174-
"indentation_is_not_a_multiple_of_four",
175-
# with flake8 3.9.0, the message ends with four spaces,
176-
# whereas in earlier versions, it ended with "four"
177-
(
178-
"flake8 error: line 2, col 3: E111 indentation is not a "
179-
"multiple of 4",
180-
),
181-
),
182-
(
183-
"BadDocstrings",
184-
"missing_whitespace_after_comma",
185-
("flake8 error: line 1, col 33: E231 missing whitespace after ','",),
186-
),
187125
(
188126
"BadDocstrings",
189127
"write_array_like_with_hyphen_not_underscore",

scripts/validate_docstrings.py

-63
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
import json
2323
import os
2424
import pathlib
25-
import subprocess
2625
import sys
27-
import tempfile
2826

2927
import matplotlib
3028
import matplotlib.pyplot as plt
@@ -64,8 +62,6 @@
6462
"SA05": "{reference_name} in `See Also` section does not need `pandas` "
6563
"prefix, use {right_reference} instead.",
6664
"EX02": "Examples do not pass tests:\n{doctest_log}",
67-
"EX03": "flake8 error: line {line_number}, col {col_number}: {error_code} "
68-
"{error_message}",
6965
"EX04": "Do not import {imported_library}, as it is imported "
7066
"automatically for the examples (numpy as np, pandas as pd)",
7167
}
@@ -198,55 +194,6 @@ def examples_source_code(self):
198194
lines = doctest.DocTestParser().get_examples(self.raw_doc)
199195
return [line.source for line in lines]
200196

201-
def validate_pep8(self):
202-
if not self.examples:
203-
return
204-
205-
# F401 is needed to not generate flake8 errors in examples
206-
# that do not user numpy or pandas
207-
content = "".join(
208-
(
209-
"import numpy as np # noqa: F401\n",
210-
"import pandas as pd # noqa: F401\n",
211-
*self.examples_source_code,
212-
)
213-
)
214-
215-
error_messages = []
216-
217-
file = tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", delete=False)
218-
try:
219-
file.write(content)
220-
file.flush()
221-
cmd = [
222-
"python",
223-
"-m",
224-
"flake8",
225-
"--format=%(row)d\t%(col)d\t%(code)s\t%(text)s",
226-
"--max-line-length=88",
227-
"--ignore=E203,E3,W503,W504,E402,E731",
228-
file.name,
229-
]
230-
response = subprocess.run(cmd, capture_output=True, check=False, text=True)
231-
for output in ("stdout", "stderr"):
232-
out = getattr(response, output)
233-
out = out.replace(file.name, "")
234-
messages = out.strip("\n").splitlines()
235-
if messages:
236-
error_messages.extend(messages)
237-
finally:
238-
file.close()
239-
os.unlink(file.name)
240-
241-
for error_message in error_messages:
242-
line_number, col_number, error_code, message = error_message.split(
243-
"\t", maxsplit=3
244-
)
245-
# Note: we subtract 2 from the line number because
246-
# 'import numpy as np\nimport pandas as pd\n'
247-
# is prepended to the docstrings.
248-
yield error_code, message, int(line_number) - 2, int(col_number)
249-
250197
def non_hyphenated_array_like(self):
251198
return "array_like" in self.raw_doc
252199

@@ -296,16 +243,6 @@ def pandas_validate(func_name: str):
296243
pandas_error("EX02", doctest_log=result["examples_errs"])
297244
)
298245

299-
for error_code, error_message, line_number, col_number in doc.validate_pep8():
300-
result["errors"].append(
301-
pandas_error(
302-
"EX03",
303-
error_code=error_code,
304-
error_message=error_message,
305-
line_number=line_number,
306-
col_number=col_number,
307-
)
308-
)
309246
examples_source_code = "".join(doc.examples_source_code)
310247
result["errors"].extend(
311248
pandas_error("EX04", imported_library=wrong_import)

0 commit comments

Comments
 (0)