Ruff ecosystem: pass no-preview cli arg by default (#8775)

Addresses
https://github.com/astral-sh/ruff/pull/8489#issuecomment-1793513411
That issues still exist on formatter, but since `black` doesn't support
`no-preview` cli arg, I didn't include it in this PR.

---------

Co-authored-by: Zanie <contact@zanie.dev>
This commit is contained in:
T-256 2023-11-20 21:51:51 +03:30 committed by GitHub
parent 10d937c1a1
commit aec80dc3ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -44,6 +44,7 @@ jobs:
- "!crates/ruff_shrinking/**" - "!crates/ruff_shrinking/**"
- scripts/* - scripts/*
- .github/workflows/ci.yaml - .github/workflows/ci.yaml
- python/**
formatter: formatter:
- Cargo.toml - Cargo.toml
@ -58,6 +59,7 @@ jobs:
- crates/ruff_python_parser/** - crates/ruff_python_parser/**
- crates/ruff_dev/** - crates/ruff_dev/**
- scripts/* - scripts/*
- python/**
- .github/workflows/ci.yaml - .github/workflows/ci.yaml
cargo-fmt: cargo-fmt:

View file

@ -71,7 +71,12 @@ class CheckOptions(CommandOptions):
max_lines_per_rule: int | None = 50 max_lines_per_rule: int | None = 50
def to_ruff_args(self) -> list[str]: def to_ruff_args(self) -> list[str]:
args = ["check", "--no-cache", "--exit-zero"] args = [
"check",
"--no-cache",
"--exit-zero",
f"--{'' if self.preview else 'no-'}preview",
]
if self.select: if self.select:
args.extend(["--select", self.select]) args.extend(["--select", self.select])
if self.ignore: if self.ignore:
@ -80,8 +85,6 @@ class CheckOptions(CommandOptions):
args.extend(["--exclude", self.exclude]) args.extend(["--exclude", self.exclude])
if self.show_fixes: if self.show_fixes:
args.extend(["--show-fixes", "--ecosystem-ci"]) args.extend(["--show-fixes", "--ecosystem-ci"])
if self.preview:
args.append("--preview")
return args return args
@ -95,11 +98,9 @@ class FormatOptions(CommandOptions):
exclude: str = "" exclude: str = ""
def to_ruff_args(self) -> list[str]: def to_ruff_args(self) -> list[str]:
args = ["format"] args = ["format", f"--{'' if self.preview else 'no-'}preview"]
if self.exclude: if self.exclude:
args.extend(["--exclude", self.exclude]) args.extend(["--exclude", self.exclude])
if self.preview:
args.append("--preview")
return args return args
def to_black_args(self) -> list[str]: def to_black_args(self) -> list[str]: