From d619f6309f6d7efe0fdd3460b5e78b22d104e03e Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Thu, 7 Dec 2023 16:44:40 -0600 Subject: [PATCH] Tighten the mypy belt once more Also, no longer stringify UUIDs preemptively, as the SDK handles this implicitly now as part of request encoding. This lets us make a data-building helper much shorter. --- mypy.ini | 3 --- src/globus_cli/services/transfer/data.py | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/mypy.ini b/mypy.ini index 1e48a03bc..0a9fae1c2 100644 --- a/mypy.ini +++ b/mypy.ini @@ -47,9 +47,6 @@ disallow_untyped_defs = false [mypy-globus_cli.services.transfer.client] disallow_untyped_defs = false -[mypy-globus_cli.services.transfer.data] -disallow_untyped_defs = false - [mypy-globus_cli.services.transfer.delegate_proxy] disallow_untyped_defs = false diff --git a/src/globus_cli/services/transfer/data.py b/src/globus_cli/services/transfer/data.py index 303849e0b..71541bf1e 100644 --- a/src/globus_cli/services/transfer/data.py +++ b/src/globus_cli/services/transfer/data.py @@ -1,7 +1,6 @@ from __future__ import annotations import typing as t -import uuid import click import globus_sdk @@ -24,7 +23,12 @@ def add_batch_to_transfer_data( @click.argument("source_path", type=TaskPath(base_dir=source_base_path)) @click.argument("dest_path", type=TaskPath(base_dir=dest_base_path)) @mutex_option_group("--recursive", "--external-checksum") - def process_batch_line(dest_path, source_path, recursive, external_checksum): + def process_batch_line( + dest_path: TaskPath, + source_path: TaskPath, + recursive: bool | None, + external_checksum: str | None, + ) -> None: """ Parse a line of batch input and turn it into a transfer submission item. @@ -44,8 +48,8 @@ def display_name_or_cname(ep_doc: dict | globus_sdk.GlobusHTTPResponse) -> str: return t.cast(str, ep_doc["display_name"] or ep_doc["canonical_name"]) -def iterable_response_to_dict(iterator): - output_dict = {"DATA": []} +def iterable_response_to_dict(iterator: t.Iterable[t.Any]) -> dict[str, list[t.Any]]: + output_dict: dict[str, list[t.Any]] = {"DATA": []} for item in iterator: dat = item try: @@ -56,12 +60,5 @@ def iterable_response_to_dict(iterator): return output_dict -def assemble_generic_doc(datatype, **kwargs): - doc = {"DATA_TYPE": datatype} - for key, val in kwargs.items(): - if isinstance(val, uuid.UUID): - val = str(val) - - if val is not None: - doc[key] = ExplicitNullType.nullify(val) - return doc +def assemble_generic_doc(datatype: str, **kwargs: t.Any) -> dict[str, t.Any]: + return ExplicitNullType.nullify_dict({"DATA_TYPE": datatype, **kwargs})