Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test-mindeps = [
"typing_extensions==4.0",
]
typing = [
"mypy==1.19.1",
"mypy==2.1.0",
"types-jwt",
"types-requests",
"types-jmespath",
Expand Down
16 changes: 12 additions & 4 deletions src/globus_cli/commands/flows/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,21 @@ class SubscriptionIdType(
name = "SUBSCRIPTION_ID"

def __init__(self, *, omittable: bool = False) -> None:
self._omittable = omittable
self._omittable: bool = omittable

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> uuid.UUID | t.Literal["DEFAULT"] | globus_sdk.MissingType:
if self._omittable and value is globus_sdk.MISSING:
return globus_sdk.MISSING
if value is globus_sdk.MISSING:
if self._omittable:
return globus_sdk.MISSING
else:
raise NotImplementedError(
"Cannot pass MISSING to non-omittable SubscriptionidType."
)

if value.upper() == "DEFAULT":
return "DEFAULT"
Expand Down
16 changes: 11 additions & 5 deletions src/globus_cli/parsing/param_types/delimited.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ def get_metavar(self, param: click.Parameter, ctx: click.Context) -> str:
return "TEXT,TEXT,..."

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> list[str] | globus_sdk.MissingType:
if self._omittable and value is globus_sdk.MISSING:
return globus_sdk.MISSING

value = super().convert(value, param, ctx)
if value is globus_sdk.MISSING:
if self._omittable:
return globus_sdk.MISSING
else:
raise NotImplementedError(
"Cannot pass MISSING to non-omittable CommaDelimitedList."
)

# if `--foo` is a comma delimited list and someone passes
# `--foo ""`, take that as `foo=[]` rather than foo=[""]
Expand Down
25 changes: 20 additions & 5 deletions src/globus_cli/parsing/param_types/omittable.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class OmittableInt(click.ParamType[int | globus_sdk.MissingType]):
name = "integer"

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> int | globus_sdk.MissingType:
if value is globus_sdk.MISSING:
return globus_sdk.MISSING
Expand All @@ -26,7 +29,10 @@ class OmittableString(click.ParamType[str | globus_sdk.MissingType]):
name = "text"

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> str | globus_sdk.MissingType:
if value is globus_sdk.MISSING:
return globus_sdk.MISSING
Expand All @@ -40,7 +46,10 @@ class OmittableUUID(click.ParamType[uuid.UUID | globus_sdk.MissingType]):
name = "uuid"

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> uuid.UUID | globus_sdk.MissingType:
if value is globus_sdk.MISSING:
return globus_sdk.MISSING
Expand All @@ -65,7 +74,10 @@ def get_missing_message(
return self._inner_choice.get_missing_message(param, ctx)

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> str | globus_sdk.MissingType:
if value is globus_sdk.MISSING:
return globus_sdk.MISSING
Expand All @@ -92,7 +104,10 @@ class OmittableDateTime(_OmittableDateTimeBase):
name = "datetime"

def convert(
self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None
self,
value: t.Any | globus_sdk.MissingType,
param: click.Parameter | None,
ctx: click.Context | None,
) -> datetime.datetime | globus_sdk.MissingType:
if value is globus_sdk.MISSING:
return globus_sdk.MISSING
Expand Down
Loading