Skip to content

Fix CLI output directory type - #182

Merged
MarcelRosier merged 3 commits into
BrainLesion:mainfrom
Vbitz:fix/cli-output-dir-type
Aug 2, 2026
Merged

Fix CLI output directory type#182
MarcelRosier merged 3 commits into
BrainLesion:mainfrom
Vbitz:fix/cli-output-dir-type

Conversation

@Vbitz

@Vbitz Vbitz commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Restore the CLI-facing output_dir annotation from str | Path to str. Typer 0.15 does not support union-typed command parameters and currently raises AssertionError: Typer Currently doesn't support Union types while constructing the command, including for preprocessor --help.

The function already converts the value with output_dir = Path(output_dir), so runtime path handling is unchanged.

Neurodesk confirmation

This investigation was started with OpenAI Codex CLI while debugging the NeuroContainers BrainLesion image, then confirmed by Neurodesk release CI:

Local validation

Tested from this branch under Python 3.10 with the project dependency set and Typer 0.15.4:

  • preprocessor --help
  • preprocessor --version

Both commands exit successfully.

@Vbitz
Vbitz marked this pull request as ready for review July 27, 2026 14:08
Copilot AI review requested due to automatic review settings July 27, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Typer CLI compatibility issue by changing the output_dir command parameter annotation from str | Path to str, avoiding Typer 0.15’s unsupported Union-typed parameters while keeping runtime behavior unchanged (the value is still converted via Path(output_dir)).

Changes:

  • Update output_dir CLI parameter type annotation from str | Path to str to prevent Typer AssertionError during command construction (e.g., preprocessor --help).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@neuronflow
neuronflow requested a review from MarcelRosier July 27, 2026 17:39

@MarcelRosier MarcelRosier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! There's actually a better approach that avoids both the union-type issue and retains the semantic correctness of Path — Typer has native Path support via Click's Path param type.

Instead of reverting to str, you can annotate with Path directly:

output_dir: Annotated[
    Path,
    typer.Option(
        "-o",
        "--output_dir",
        help="The path to the output directory",
        exists=False,       # output dir doesn't need to exist yet
        file_okay=False,    # must be a directory, not a file
        dir_okay=True,
        resolve_path=True,
    ),
],

Typer/Click handles the strPath conversion automatically (no union needed), so you can also remove the manual output_dir = Path(output_dir) on line 92.

This gives you the correct type annotation, Typer 0.15 compatibility, and optional path validation for free.

@neuronflow

Copy link
Copy Markdown
Collaborator

@Vbitz please adress @MarcelRosier's comment ;)

@Vbitz

Vbitz commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for your review :) Pushed a fix.

@MarcelRosier
MarcelRosier enabled auto-merge August 2, 2026 14:37
@MarcelRosier
MarcelRosier merged commit c42b5eb into BrainLesion:main Aug 2, 2026
5 checks passed
@Vbitz
Vbitz deleted the fix/cli-output-dir-type branch August 2, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants