Skip to content

Commit b643061

Browse files
authored
Remove the 'UUIDLike' type alias (#1258)
This is not strictly necessary and importantly it isn't interpreted as we'd like by Sphinx, so users are seeing the `UUIDLike` name in our docs instead of the union. <!-- readthedocs-preview globus-sdk-python start --> ---- 📚 Documentation preview 📚: https://globus-sdk-python--1258.org.readthedocs.build/en/1258/ <!-- readthedocs-preview globus-sdk-python end -->
1 parent 5b3ed1f commit b643061

35 files changed

Lines changed: 307 additions & 293 deletions

src/globus_sdk/_guards.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import typing as t
55
import uuid
66

7-
from globus_sdk._types import UUIDLike
8-
97
# some error types use guards, so import from the specific module to avoid circularity
108
from globus_sdk.exc.base import ValidationError
119

@@ -94,7 +92,7 @@ def instance_or_dict(name: str, value: t.Any, cls: type[S]) -> S:
9492
)
9593

9694
@staticmethod
97-
def uuidlike(name: str, s: t.Any) -> UUIDLike:
95+
def uuidlike(name: str, s: t.Any) -> uuid.UUID | str:
9896
"""
9997
Raise an error if the input is not a UUID
10098
@@ -108,7 +106,7 @@ def uuidlike(name: str, s: t.Any) -> UUIDLike:
108106
109107
.. code-block:: python
110108
111-
def frob_it(collection_id: UUIDLike) -> Frob:
109+
def frob_it(collection_id: uuid.UUID | str) -> Frob:
112110
validators.uuidlike(collection_id, name="collection_id")
113111
return Frob(collection_id)
114112

src/globus_sdk/_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
import datetime
44
import typing as t
5-
import uuid
65

76
if t.TYPE_CHECKING:
87
from globus_sdk.scopes import MutableScope, Scope
98

109

1110
# these types are aliases meant for internal use
1211
IntLike = t.Union[int, str]
13-
UUIDLike = t.Union[uuid.UUID, str]
1412
DateLike = t.Union[str, datetime.datetime]
1513

1614
ScopeCollectionType = t.Union[

src/globus_sdk/globus_app/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import contextlib
55
import copy
66
import typing as t
7+
import uuid
78

89
from globus_sdk import (
910
AuthClient,
@@ -12,7 +13,7 @@
1213
IDTokenDecoder,
1314
Scope,
1415
)
15-
from globus_sdk._types import ScopeCollectionType, UUIDLike
16+
from globus_sdk._types import ScopeCollectionType
1617
from globus_sdk.authorizers import GlobusAuthorizer
1718
from globus_sdk.gare import GlobusAuthorizationParameters
1819
from globus_sdk.scopes import AuthScopes, scopes_to_scope_list
@@ -65,7 +66,7 @@ def __init__(
6566
app_name: str = "Unnamed Globus App",
6667
*,
6768
login_client: AuthLoginClient | None = None,
68-
client_id: UUIDLike | None = None,
69+
client_id: uuid.UUID | str | None = None,
6970
client_secret: str | None = None,
7071
scope_requirements: t.Mapping[str, ScopeCollectionType] | None = None,
7172
config: GlobusAppConfig = DEFAULT_CONFIG,
@@ -135,9 +136,9 @@ def _resolve_client_info(
135136
app_name: str,
136137
config: GlobusAppConfig,
137138
login_client: AuthLoginClient | None,
138-
client_id: UUIDLike | None,
139+
client_id: uuid.UUID | str | None,
139140
client_secret: str | None,
140-
) -> tuple[UUIDLike, AuthLoginClient]:
141+
) -> tuple[uuid.UUID | str, AuthLoginClient]:
141142
"""
142143
Extracts a client_id and login_client from GlobusApp initialization parameters,
143144
validating that the parameters were provided correctly.
@@ -188,7 +189,7 @@ def _initialize_login_client(
188189
self,
189190
app_name: str,
190191
config: GlobusAppConfig,
191-
client_id: UUIDLike,
192+
client_id: uuid.UUID | str,
192193
client_secret: str | None,
193194
) -> AuthLoginClient:
194195
"""
@@ -216,7 +217,7 @@ def _initialize_validating_token_storage(
216217
return validating_token_storage
217218

218219
def _resolve_token_storage(
219-
self, app_name: str, client_id: UUIDLike, config: GlobusAppConfig
220+
self, app_name: str, client_id: uuid.UUID | str, config: GlobusAppConfig
220221
) -> TokenStorage:
221222
"""
222223
Resolve the raw token storage to be used by the app.

src/globus_sdk/globus_app/client_app.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from __future__ import annotations
22

3+
import uuid
4+
35
from globus_sdk import AuthLoginClient, ConfidentialAppAuthClient, GlobusSDKUsageError
4-
from globus_sdk._types import ScopeCollectionType, UUIDLike
6+
from globus_sdk._types import ScopeCollectionType
57
from globus_sdk.gare import GlobusAuthorizationParameters
68

79
from .app import GlobusApp
@@ -55,7 +57,7 @@ def __init__(
5557
app_name: str = "Unnamed Globus App",
5658
*,
5759
login_client: ConfidentialAppAuthClient | None = None,
58-
client_id: UUIDLike | None = None,
60+
client_id: uuid.UUID | str | None = None,
5961
client_secret: str | None = None,
6062
scope_requirements: dict[str, ScopeCollectionType] | None = None,
6163
config: GlobusAppConfig = DEFAULT_CONFIG,
@@ -81,7 +83,7 @@ def _initialize_login_client(
8183
self,
8284
app_name: str,
8385
config: GlobusAppConfig,
84-
client_id: UUIDLike,
86+
client_id: uuid.UUID | str,
8587
client_secret: str | None,
8688
) -> AuthLoginClient:
8789
if not client_secret:

src/globus_sdk/globus_app/protocols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

33
import typing as t
4+
import uuid
45

56
if t.TYPE_CHECKING:
67
from globus_sdk import AuthLoginClient, IDTokenDecoder
7-
from globus_sdk._types import UUIDLike
88
from globus_sdk.login_flows import LoginFlowManager
99
from globus_sdk.tokenstorage import TokenStorage, TokenValidationError
1010

@@ -26,7 +26,7 @@ def for_globus_app(
2626
*,
2727
app_name: str,
2828
config: GlobusAppConfig,
29-
client_id: UUIDLike,
29+
client_id: uuid.UUID | str,
3030
namespace: str,
3131
) -> TokenStorage:
3232
"""

src/globus_sdk/globus_app/user_app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import typing as t
4+
import uuid
45

56
from globus_sdk import (
67
AuthClient,
@@ -10,7 +11,7 @@
1011
NativeAppAuthClient,
1112
Scope,
1213
)
13-
from globus_sdk._types import ScopeCollectionType, UUIDLike
14+
from globus_sdk._types import ScopeCollectionType
1415
from globus_sdk.gare import GlobusAuthorizationParameters
1516
from globus_sdk.login_flows import CommandLineLoginFlowManager, LoginFlowManager
1617
from globus_sdk.tokenstorage import (
@@ -78,7 +79,7 @@ def __init__(
7879
app_name: str = "Unnamed Globus App",
7980
*,
8081
login_client: AuthLoginClient | None = None,
81-
client_id: UUIDLike | None = None,
82+
client_id: uuid.UUID | str | None = None,
8283
client_secret: str | None = None,
8384
scope_requirements: t.Mapping[str, ScopeCollectionType] | None = None,
8485
config: GlobusAppConfig = DEFAULT_CONFIG,
@@ -127,7 +128,7 @@ def _initialize_login_client(
127128
self,
128129
app_name: str,
129130
config: GlobusAppConfig,
130-
client_id: UUIDLike,
131+
client_id: uuid.UUID | str,
131132
client_secret: str | None,
132133
) -> AuthLoginClient:
133134
if client_secret:

src/globus_sdk/scopes/consents/_model.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727

2828
import textwrap
2929
import typing as t
30+
import uuid
3031
from dataclasses import dataclass
3132
from datetime import datetime
3233

33-
from globus_sdk._types import UUIDLike
34-
3534
from ..representation import Scope
3635
from ._errors import ConsentParseError, ConsentTreeConstructionError
3736

@@ -49,11 +48,11 @@ class Consent:
4948
operations (consents) defined in the "dependency_path".
5049
"""
5150

52-
client: UUIDLike
53-
scope: UUIDLike
51+
client: uuid.UUID | str
52+
scope: uuid.UUID | str
5453
scope_name: str
5554
id: int
56-
effective_identity: UUIDLike
55+
effective_identity: uuid.UUID | str
5756
# A list representing the path of consent dependencies leading from a "root consent"
5857
# to this. The last element of this list will always be this consent's ID.
5958
# Downstream dependency relationships may exist but will not be defined here.

src/globus_sdk/scopes/data/flows.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from __future__ import annotations
22

33
import typing as t
4-
5-
from globus_sdk._types import UUIDLike
4+
import uuid
65

76
from ..builder import ScopeBuilder, ScopeBuilderScopes
87

@@ -105,7 +104,7 @@ class SpecificFlowScopeBuilder(ScopeBuilder):
105104

106105
_CLASS_STUB = _SpecificFlowScopesClassStub()
107106

108-
def __init__(self, flow_id: UUIDLike) -> None:
107+
def __init__(self, flow_id: uuid.UUID | str) -> None:
109108
self._flow_id = flow_id
110109
str_flow_id = str(flow_id)
111110
super().__init__(

src/globus_sdk/services/auth/client/base_login_client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import logging
44
import typing as t
5+
import uuid
56

67
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
78

89
from globus_sdk import _guards, client, exc, utils
9-
from globus_sdk._types import UUIDLike
1010
from globus_sdk.authorizers import GlobusAuthorizer, NullAuthorizer
1111
from globus_sdk.response import GlobusHTTPResponse
1212
from globus_sdk.scopes import AuthScopes, Scope
@@ -45,7 +45,7 @@ class AuthLoginClient(client.BaseClient):
4545

4646
def __init__(
4747
self,
48-
client_id: UUIDLike | None = None,
48+
client_id: uuid.UUID | str | None = None,
4949
environment: str | None = None,
5050
base_url: str | None = None,
5151
authorizer: GlobusAuthorizer | None = None,
@@ -141,9 +141,13 @@ def get_jwk(
141141
def oauth2_get_authorize_url(
142142
self,
143143
*,
144-
session_required_identities: UUIDLike | t.Iterable[UUIDLike] | None = None,
144+
session_required_identities: (
145+
uuid.UUID | str | t.Iterable[uuid.UUID | str] | None
146+
) = None,
145147
session_required_single_domain: str | t.Iterable[str] | None = None,
146-
session_required_policies: UUIDLike | t.Iterable[UUIDLike] | None = None,
148+
session_required_policies: (
149+
uuid.UUID | str | t.Iterable[uuid.UUID | str] | None
150+
) = None,
147151
session_required_mfa: bool | None = None,
148152
session_message: str | None = None,
149153
prompt: t.Literal["login"] | None = None,

src/globus_sdk/services/auth/client/confidential_client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import logging
44
import typing as t
5+
import uuid
56

67
from globus_sdk import exc, utils
7-
from globus_sdk._types import ScopeCollectionType, UUIDLike
8+
from globus_sdk._types import ScopeCollectionType
89
from globus_sdk.authorizers import BasicAuthorizer
910
from globus_sdk.response import GlobusHTTPResponse
1011

@@ -44,7 +45,7 @@ class ConfidentialAppAuthClient(AuthLoginClient):
4445

4546
def __init__(
4647
self,
47-
client_id: UUIDLike,
48+
client_id: uuid.UUID | str,
4849
client_secret: str,
4950
environment: str | None = None,
5051
base_url: str | None = None,
@@ -64,7 +65,7 @@ def get_identities(
6465
self,
6566
*,
6667
usernames: t.Iterable[str] | str | None = None,
67-
ids: t.Iterable[UUIDLike] | UUIDLike | None = None,
68+
ids: t.Iterable[uuid.UUID | str] | uuid.UUID | str | None = None,
6869
provision: bool = False,
6970
query_params: dict[str, t.Any] | None = None,
7071
) -> GetIdentitiesResponse:
@@ -344,8 +345,8 @@ def create_child_client(
344345
redirect_uris: t.Iterable[str] | utils.MissingType = utils.MISSING,
345346
terms_and_conditions: str | utils.MissingType = utils.MISSING,
346347
privacy_policy: str | utils.MissingType = utils.MISSING,
347-
required_idp: UUIDLike | utils.MissingType = utils.MISSING,
348-
preselect_idp: UUIDLike | utils.MissingType = utils.MISSING,
348+
required_idp: uuid.UUID | str | utils.MissingType = utils.MISSING,
349+
preselect_idp: uuid.UUID | str | utils.MissingType = utils.MISSING,
349350
additional_fields: dict[str, t.Any] | utils.MissingType = utils.MISSING,
350351
) -> GlobusHTTPResponse:
351352
"""

0 commit comments

Comments
 (0)