Skip to content

inconsistent type hint definitions for CLI interfaces

For example, plot-scan has

@app.command()
def main(
    connectivity_files: List[Path] = OPTIONS["connectivity_files"],
    ...
)

where the option is defined as

OPTIONS["connectivity_files"]: List[Path] = typer.Option(
    None,
    "-c",
    "--connectivity-files",
    help="path to one or more connectivity file.",
    exists=True,
    file_okay=True,
    readable=True,
    resolve_path=True,
)

however, this is wrong for two different reasons.

  1. if this option is meant to be required, it should not have a default value of None.
  2. if this option is not meant to be required, it should have a type-hint of Optional[List[Path]] to specify that this is an OPTIONAL value.