Skip to content

Commit de06ec8

Browse files
author
awu42
committed
Edited validate_rst_title_capitalization.py for review (pandas-dev#29641)
1 parent 1907d45 commit de06ec8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/validate_rst_title_capitalization.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class suppress_stdout_stderr:
3636
'''
3737
Code source:
38-
https://stackoverflow.com/questions/11130156/suppress-stdout-stderr-print-from-python-functions
38+
https://stackoverflow.com/questions/11130156/
3939
4040
A context manager for doing a "deep suppression" of stdout and stderr in
4141
Python, i.e. will suppress all print, even if the print originates in a
@@ -50,7 +50,7 @@ class suppress_stdout_stderr:
5050
5151
'''
5252
def __init__(self):
53-
self.null_fds = [os.open(os.devnull, os.O_RDWR) for x in range(2)]
53+
self.null_fds = [os.open(os.devnull, os.O_WRONLY) for x in range(2)]
5454
self.save_fds = [os.dup(1), os.dup(2)]
5555

5656
def __enter__(self):
@@ -210,9 +210,8 @@ def parse_RST(rst_file: str) -> docutils.nodes.document:
210210
# Initialize an empty document tree with the default settings from above
211211
document = docutils.utils.new_document('Document', settings)
212212

213-
# Parse input into an RST doctree, suppressing any stdout from parse method
214-
with suppress_stdout_stderr():
215-
parser.parse(input, document)
213+
# Parse input into an RST doctree, suppressing any stderr from parse method
214+
parser.parse(input, document)
216215

217216
# Return the root node of the document tree
218217
return document
@@ -423,8 +422,9 @@ def main(source_paths: List[str], output_format: str) -> bool:
423422
directory_list = find_rst_files(source_paths)
424423

425424
# Fill the bad_title_dict, which contains all incorrectly capitalized headings
426-
for filename in directory_list:
427-
fill_bad_title_dict(filename)
425+
with suppress_stdout_stderr():
426+
for filename in directory_list:
427+
fill_bad_title_dict(filename)
428428

429429
# Return an exit status of 0 if there are no bad titles in the dictionary
430430
if (len(bad_title_dict) == 0):

0 commit comments

Comments
 (0)