Skip to content

Commit 31fb4dd

Browse files
committed
Revert "[skip ci] Integrate flake8 and flake8-rst into validate_docstrings.py"
This reverts commit ee36f34 Signed-off-by: Fabian Haase <haase.fabian@gmail.com>
1 parent ee36f34 commit 31fb4dd

File tree

1 file changed

+12
-45
lines changed

1 file changed

+12
-45
lines changed

scripts/validate_docstrings.py

+12-45
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
$ ./validate_docstrings.py pandas.DataFrame.head
1515
"""
1616
import os
17-
import subprocess
1817
import sys
1918
import json
2019
import re
@@ -25,7 +24,6 @@
2524
import inspect
2625
import importlib
2726
import doctest
28-
2927
try:
3028
from io import StringIO
3129
except ImportError:
@@ -42,6 +40,7 @@
4240
from numpydoc.docscrape import NumpyDocString
4341
from pandas.io.formats.printing import pprint_thing
4442

43+
4544
PRIVATE_CLASSES = ['NDFrame', 'IndexOpsMixin']
4645
DIRECTIVES = ['versionadded', 'versionchanged', 'deprecated']
4746

@@ -530,16 +529,15 @@ def validate_one(func_name):
530529
if examples_errs:
531530
errs.append('Examples do not pass tests')
532531

533-
return ({'type': doc.type,
534-
'docstring': doc.clean_doc,
535-
'deprecated': doc.deprecated,
536-
'file': doc.source_file_name,
537-
'file_line': doc.source_file_def_line,
538-
'github_link': doc.github_url,
539-
'errors': errs,
540-
'warnings': wrns,
541-
'examples_errors': examples_errs},
542-
doc)
532+
return {'type': doc.type,
533+
'docstring': doc.clean_doc,
534+
'deprecated': doc.deprecated,
535+
'file': doc.source_file_name,
536+
'file_line': doc.source_file_def_line,
537+
'github_link': doc.github_url,
538+
'errors': errs,
539+
'warnings': wrns,
540+
'examples_errors': examples_errs}
543541

544542

545543
def validate_all():
@@ -600,15 +598,10 @@ def header(title, width=80, char='#'):
600598
full_line=full_line, title_line=title_line)
601599

602600
if func_name is None:
603-
flake8 = _call_flake8_plugin()
604-
if flake8:
605-
fd.write('Flake8 reported issues:\n')
606-
fd.write(flake8)
607-
608601
json_doc = validate_all()
609602
fd.write(json.dumps(json_doc))
610603
else:
611-
doc_info, doc = validate_one(func_name)
604+
doc_info = validate_one(func_name)
612605

613606
fd.write(header('Docstring ({})'.format(func_name)))
614607
fd.write('{}\n'.format(doc_info['docstring']))
@@ -622,40 +615,14 @@ def header(title, width=80, char='#'):
622615
for wrn in doc_info['warnings']:
623616
fd.write('\t{}\n'.format(wrn))
624617

625-
flake8 = _call_flake8_plugin(doc.source_file_name)
626-
if flake8:
627-
fd.write('Flake8 reported issues:\n')
628-
fd.write(flake8)
629-
630-
if not doc_info['errors'] and not flake8:
618+
if not doc_info['errors']:
631619
fd.write('Docstring for "{}" correct. :)\n'.format(func_name))
632620

633621
if doc_info['examples_errors']:
634622
fd.write(header('Doctests'))
635623
fd.write(doc_info['examples_errors'])
636624

637625

638-
def _call_flake8_plugin(*source_file_name):
639-
sub_cmds = (['flake8', '--doctest', *source_file_name],
640-
['flake8-rst', *source_file_name])
641-
642-
check_output = [_check_output_safe(sub_cmd) for sub_cmd in sub_cmds]
643-
output = [output for output in check_output if output]
644-
return '\n\n'.join(output) if output else None
645-
646-
647-
def _check_output_safe(sub_cmd):
648-
try:
649-
output = subprocess.check_output(sub_cmd)
650-
except subprocess.CalledProcessError as e:
651-
output = e.output
652-
if output:
653-
return '\n'.join(['Invoking command "{}" returned:'
654-
.format(' '.join(sub_cmd)), output.decode("utf-8")])
655-
else:
656-
return None
657-
658-
659626
if __name__ == '__main__':
660627
func_help = ('function or method to validate (e.g. pandas.DataFrame.head) '
661628
'if not provided, all docstrings are validated and returned '

0 commit comments

Comments
 (0)