From 16e511a7347977488f379dffb5a43d4ef98905bc Mon Sep 17 00:00:00 2001 From: Zanie Date: Fri, 27 Oct 2023 15:46:33 -0500 Subject: [PATCH] Use `FormatOptions`; exclude file from `demisto/content` with syntax error --- python/ruff-ecosystem/ruff_ecosystem/defaults.py | 10 ++++++++-- python/ruff-ecosystem/ruff_ecosystem/format.py | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/python/ruff-ecosystem/ruff_ecosystem/defaults.py b/python/ruff-ecosystem/ruff_ecosystem/defaults.py index 472860f5bb..0627d563c0 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/defaults.py +++ b/python/ruff-ecosystem/ruff_ecosystem/defaults.py @@ -1,7 +1,7 @@ """ Default projects for ecosystem checks """ -from ruff_ecosystem.projects import CheckOptions, Project, Repository +from ruff_ecosystem.projects import CheckOptions, Project, Repository, FormatOptions # TODO(zanieb): Consider exporting this as JSON and loading from there instead DEFAULT_TARGETS = [ @@ -22,7 +22,13 @@ DEFAULT_TARGETS = [ check_options=CheckOptions(select="ALL"), ), Project(repo=Repository(owner="commaai", name="openpilot", ref="master")), - Project(repo=Repository(owner="demisto", name="content", ref="master")), + Project( + repo=Repository(owner="demisto", name="content", ref="master"), + format_options=FormatOptions( + # Syntax errors in this file + exclude="Packs/ThreatQ/Integrations/ThreatQ/ThreatQ.py" + ), + ), Project(repo=Repository(owner="docker", name="docker-py", ref="main")), Project(repo=Repository(owner="freedomofpress", name="securedrop", ref="develop")), Project(repo=Repository(owner="fronzbot", name="blinkpy", ref="dev")), diff --git a/python/ruff-ecosystem/ruff_ecosystem/format.py b/python/ruff-ecosystem/ruff_ecosystem/format.py index 473a7aa4e3..686515521e 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/format.py +++ b/python/ruff-ecosystem/ruff_ecosystem/format.py @@ -154,7 +154,7 @@ async def ruff_format( ) -> Sequence[str]: """Run the given ruff binary against the specified path.""" logger.debug(f"Formatting {name} with {executable}") - ruff_args = ["format"] + ruff_args = options.to_cli_args() if diff: ruff_args.append("--diff") @@ -186,6 +186,10 @@ class FormatOptions: Ruff format options. """ + exclude: str = "" + def to_cli_args(self) -> list[str]: - args = ["format", "--diff"] + args = ["format"] + if self.exclude: + args.extend(["--exclude", self.exclude]) return args