From 54f24fdc8e533a7d665048fa3dd5e46edbb80aec Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 11 Oct 2022 15:32:47 -0400 Subject: [PATCH] support multiple files to work correctly w/ pre-commit Change-Id: I7ddf1848b96105701b733306353ae949a4579339 --- tools/format_docs_code.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/format_docs_code.py b/tools/format_docs_code.py index 31a5b8e2ff..05e5e01f10 100644 --- a/tools/format_docs_code.py +++ b/tools/format_docs_code.py @@ -283,9 +283,11 @@ def iter_files(directory: str) -> Iterator[Path]: ) -def main(file: str | None, directory: str, exit_on_error: bool, check: bool): +def main( + file: list[str] | None, directory: str, exit_on_error: bool, check: bool +): if file is not None: - result = [format_file(Path(file), exit_on_error, check)] + result = [format_file(Path(f), exit_on_error, check) for f in file] else: result = [ format_file(doc, exit_on_error, check) @@ -327,7 +329,10 @@ Use --report-doctest to ignore errors on plain code blocks. formatter_class=RawDescriptionHelpFormatter, ) parser.add_argument( - "-f", "--file", help="Format only this file instead of all docs" + "-f", + "--file", + help="Format only this file instead of all docs", + nargs="+", ) parser.add_argument( "-d", @@ -357,7 +362,8 @@ Use --report-doctest to ignore errors on plain code blocks. action="store_true", ) parser.add_argument( - "-rd", "--report-doctest", + "-rd", + "--report-doctest", help="Report errors only when running doctest blocks. When active " "exit-on-error will be valid only on doctest blocks", action="store_true", -- 2.47.3