From: Mike Bayer Date: Tue, 11 Oct 2022 19:32:47 +0000 (-0400) Subject: support multiple files to work correctly w/ pre-commit X-Git-Tag: rel_1_4_42~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54f24fdc8e533a7d665048fa3dd5e46edbb80aec;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git support multiple files to work correctly w/ pre-commit Change-Id: I7ddf1848b96105701b733306353ae949a4579339 --- 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",