From 75f8fc7699cc33243ddd06eb227d37ff2245fa7f Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Tue, 7 Jan 2025 14:03:10 -0500 Subject: [PATCH] Typer does not support Union types. --- tiled/commandline/_api_key.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tiled/commandline/_api_key.py b/tiled/commandline/_api_key.py index 27b07be97..0a83b3740 100644 --- a/tiled/commandline/_api_key.py +++ b/tiled/commandline/_api_key.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Union +from typing import List, Optional import typer @@ -12,7 +12,7 @@ def create_api_key( profile: Optional[str] = typer.Option( None, help="If you use more than one Tiled server, use this to specify which." ), - expires_in: Optional[Union[int, str]] = typer.Option( + expires_in: Optional[str] = typer.Option( None, help=( "Number of seconds until API key expires, given as integer seconds " @@ -36,6 +36,8 @@ def create_api_key( # This is how typer interprets unspecified scopes. # Replace with None to get default scopes. scopes = None + if expires_in.isdigit(): + expires_in = int(expires_in) info = context.create_api_key(scopes=scopes, expires_in=expires_in, note=note) # TODO Print other info to the stderr? typer.echo(info["secret"])