fix(agent, benchmark): Specify path_type=Path for CLI path options/arguments

Without `path_type=Path`, an option/argument with `type=click.Path()` will return a `str`.
This commit is contained in:
Reinier van der Leer
2024-07-03 15:21:04 -06:00
parent 08612cc3bf
commit db0e726954
4 changed files with 9 additions and 4 deletions

View File

@@ -113,7 +113,7 @@ def cli(ctx: click.Context):
@click.option(
"--component-config-file",
help="Path to a json configuration file",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
type=click.Path(exists=True, dir_okay=False, resolve_path=True, path_type=Path),
)
def run(
continuous: bool,

View File

@@ -19,7 +19,7 @@ from autogpt.app.utils import coroutine
help="Path to the git repository",
)
@coroutine
async def generate_release_notes(repo_path: Optional[Path] = None):
async def generate_release_notes(repo_path: Optional[str | Path] = None):
logger = logging.getLogger(generate_release_notes.name) # pyright: ignore
repo = Repo(repo_path, search_parent_directories=True)

View File

@@ -97,7 +97,9 @@ def start():
help="Write log output to a file instead of the terminal.",
)
# @click.argument(
# "agent_path", type=click.Path(exists=True, file_okay=False), required=False
# "agent_path",
# type=click.Path(exists=True, file_okay=False, path_type=Path),
# required=False,
# )
def run(
maintain: bool,

View File

@@ -1,13 +1,16 @@
#!/usr/bin/env python3
from pathlib import Path
import click
from agbenchmark.reports.processing.report_types import Report
@click.command()
@click.argument("report_json_file", type=click.Path(exists=True, dir_okay=False))
@click.argument(
"report_json_file", type=click.Path(exists=True, dir_okay=False, path_type=Path)
)
def print_markdown_report(report_json_file: Path):
"""
Generates a Markdown report from a given report.json file.