mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:37 +00:00
[red-knot] knot benchmark: fix --knot-path
arg (#13923)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz (push) Blocked by required conditions
CI / Fuzz the parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz (push) Blocked by required conditions
CI / Fuzz the parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
## Summary Previously, this would fail with ``` AttributeError: 'str' object has no attribute 'is_file' ``` if I tried to use the `--knot-path` option. I wish we had a type checker for Python*. ## Test Plan ```sh uv run benchmark --knot-path ~/.cargo-target/release/red_knot ``` \* to be fair, this would probably require special handling for `argparse` in the typechecker.
This commit is contained in:
parent
32b57b2ee4
commit
085a43a262
3 changed files with 10 additions and 11 deletions
|
@ -154,12 +154,12 @@ class Venv:
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self) -> str:
|
||||||
"""The name of the virtual environment directory."""
|
"""The name of the virtual environment directory."""
|
||||||
return self.path.name
|
return self.path.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def python(self):
|
def python(self) -> Path:
|
||||||
"""Returns the path to the python executable"""
|
"""Returns the path to the python executable"""
|
||||||
return self.script("python")
|
return self.script("python")
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class Venv:
|
||||||
root = parent / "venv"
|
root = parent / "venv"
|
||||||
return Venv(root)
|
return Venv(root)
|
||||||
|
|
||||||
def install(self, dependencies: list[str]):
|
def install(self, dependencies: list[str]) -> None:
|
||||||
"""Installs the dependencies required to type check the project."""
|
"""Installs the dependencies required to type check the project."""
|
||||||
|
|
||||||
logging.debug(f"Installing dependencies: {', '.join(dependencies)}")
|
logging.debug(f"Installing dependencies: {', '.join(dependencies)}")
|
||||||
|
@ -202,7 +202,7 @@ class Venv:
|
||||||
"pip",
|
"pip",
|
||||||
"install",
|
"install",
|
||||||
"--python",
|
"--python",
|
||||||
self.python,
|
self.python.as_posix(),
|
||||||
"--quiet",
|
"--quiet",
|
||||||
# We pass `--exclude-newer` to ensure that type-checking of one of
|
# We pass `--exclude-newer` to ensure that type-checking of one of
|
||||||
# our projects isn't unexpectedly broken by a change in the
|
# our projects isn't unexpectedly broken by a change in the
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import typing
|
import typing
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -30,9 +29,9 @@ class Project(typing.NamedTuple):
|
||||||
mypy_arguments: list[str] | None = None
|
mypy_arguments: list[str] | None = None
|
||||||
"""The arguments passed to mypy. Overrides `include` if set."""
|
"""The arguments passed to mypy. Overrides `include` if set."""
|
||||||
|
|
||||||
def clone(self, checkout_dir: Path):
|
def clone(self, checkout_dir: Path) -> None:
|
||||||
# Skip cloning if the project has already been cloned (the script doesn't yet support updating)
|
# Skip cloning if the project has already been cloned (the script doesn't yet support updating)
|
||||||
if os.path.exists(os.path.join(checkout_dir, ".git")):
|
if (checkout_dir / ".git").exists():
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.debug(f"Cloning {self.repository} to {checkout_dir}")
|
logging.debug(f"Cloning {self.repository} to {checkout_dir}")
|
||||||
|
|
|
@ -16,7 +16,7 @@ if typing.TYPE_CHECKING:
|
||||||
from benchmark.cases import Tool
|
from benchmark.cases import Tool
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
"""Run the benchmark."""
|
"""Run the benchmark."""
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Benchmark knot against other packaging tools."
|
description="Benchmark knot against other packaging tools."
|
||||||
|
@ -69,7 +69,7 @@ def main():
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--knot-path",
|
"--knot-path",
|
||||||
type=str,
|
type=Path,
|
||||||
help="Path(s) to the red_knot binary to benchmark.",
|
help="Path(s) to the red_knot binary to benchmark.",
|
||||||
action="append",
|
action="append",
|
||||||
)
|
)
|
||||||
|
@ -116,8 +116,8 @@ def main():
|
||||||
]
|
]
|
||||||
|
|
||||||
for project in projects:
|
for project in projects:
|
||||||
with tempfile.TemporaryDirectory() as cwd:
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
cwd = Path(cwd)
|
cwd = Path(tempdir)
|
||||||
project.clone(cwd)
|
project.clone(cwd)
|
||||||
|
|
||||||
venv = Venv.create(cwd)
|
venv = Venv.create(cwd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue