Add some ruff autofixes to CI (#10458)

This commit is contained in:
Alex Waygood
2023-07-20 13:41:52 +01:00
committed by GitHub
parent a04cb3b058
commit 79e092e133
8 changed files with 62 additions and 6 deletions

View File

@@ -65,6 +65,11 @@ def run_isort(stub_dir: str) -> None:
subprocess.run([sys.executable, "-m", "isort", stub_dir])
def run_ruff(stub_dir: str) -> None:
print(f"Running ruff: ruff {stub_dir}")
subprocess.run([sys.executable, "-m", "ruff", stub_dir])
def create_metadata(stub_dir: str, version: str) -> None:
"""Create a METADATA.toml file."""
match = re.match(r"[0-9]+.[0-9]+", version)
@@ -110,7 +115,7 @@ def add_pyright_exclusion(stub_dir: str) -> None:
def main() -> None:
parser = argparse.ArgumentParser(
description="""Generate baseline stubs automatically for an installed pip package
using stubgen. Also run black and isort. If the name of
using stubgen. Also run black, isort and ruff. If the name of
the project is different from the runtime Python package name, you may
need to use --package (example: --package yaml PyYAML)."""
)
@@ -159,6 +164,7 @@ def main() -> None:
run_stubgen(package, stub_dir)
run_stubdefaulter(stub_dir)
run_ruff(stub_dir)
run_isort(stub_dir)
run_black(stub_dir)

View File

@@ -77,6 +77,8 @@ def main() -> None:
# Run formatters first. Order matters.
print("\nRunning pycln...")
subprocess.run([sys.executable, "-m", "pycln", path, "--config=pyproject.toml"])
print("\nRunning ruff...")
subprocess.run([sys.executable, "-m", "ruff", path])
print("\nRunning isort...")
subprocess.run([sys.executable, "-m", "isort", path])
print("\nRunning Black...")