Skip to content

Commit

Permalink
Remove literal type alias to help sphinx render (#1129)
Browse files Browse the repository at this point in the history
This type alias is used in 3 locations (two of which are internal),
but sphinx autodoc does not render it as desired or expected. It seems
that there's something more complex going wrong with the docstring for
this class, but it may also be related to some outstanding sphinx bugs
related to type aliases and literals, specifically.

For now, switch off of the alias and use the literal verbatim in
`TransferData.__init__` to get a rendering which is much closer to
being correct.
  • Loading branch information
sirosen authored Jan 14, 2025
1 parent f434f8e commit fdebea0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/globus_sdk/services/transfer/data/transfer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
import globus_sdk

log = logging.getLogger(__name__)
_StrSyncLevel = t.Literal["exists", "size", "mtime", "checksum"]
_sync_level_dict: dict[_StrSyncLevel, int] = {
_sync_level_dict: dict[t.Literal["exists", "size", "mtime", "checksum"], int] = {
"exists": 0,
"size": 1,
"mtime": 2,
"checksum": 3,
}


def _parse_sync_level(sync_level: _StrSyncLevel | int) -> int:
def _parse_sync_level(
sync_level: t.Literal["exists", "size", "mtime", "checksum"] | int
) -> int:
"""
Map sync_level strings to known int values
Expand Down Expand Up @@ -168,7 +169,9 @@ def __init__(
*,
label: str | None = None,
submission_id: UUIDLike | None = None,
sync_level: _StrSyncLevel | int | None = None,
sync_level: (
int | None | t.Literal["exists", "size", "mtime", "checksum"]
) = None,
verify_checksum: bool = False,
preserve_timestamp: bool = False,
encrypt_data: bool = False,
Expand Down

0 comments on commit fdebea0

Please sign in to comment.