Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the return type annotation for get_identities #716

Merged
merged 1 commit into from
Apr 14, 2023
Merged
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: 2 additions & 0 deletions changelog.d/20230412_144457_sirosen_fix_type_error.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* The return type of ``AuthClient.get_identities`` is now correctly annotated as
an iterable type, ``globus_sdk.GetIdentitiesResponse`` (:pr:`NUMBER`)
3 changes: 3 additions & 0 deletions src/globus_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def _force_eager_imports() -> None:
"ConfidentialAppAuthClient",
"IdentityMap",
"NativeAppAuthClient",
"GetIdentitiesResponse",
"OAuthDependentTokenResponse",
"OAuthTokenResponse",
},
Expand Down Expand Up @@ -151,6 +152,7 @@ def _force_eager_imports() -> None:
from .services.auth import ConfidentialAppAuthClient
from .services.auth import IdentityMap
from .services.auth import NativeAppAuthClient
from .services.auth import GetIdentitiesResponse
from .services.auth import OAuthDependentTokenResponse
from .services.auth import OAuthTokenResponse
from .services.gcs import CollectionDocument
Expand Down Expand Up @@ -260,6 +262,7 @@ def __getattr__(name: str) -> t.Any:
"GCSAPIError",
"GCSClient",
"GCSRoleDocument",
"GetIdentitiesResponse",
"GlobusAPIError",
"GlobusConnectPersonalOwnerInfo",
"GlobusConnectionError",
Expand Down
1 change: 1 addition & 0 deletions src/globus_sdk/_generate_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __getattr__(name: str) -> t.Any:
"ConfidentialAppAuthClient",
"IdentityMap",
"NativeAppAuthClient",
"GetIdentitiesResponse",
"OAuthDependentTokenResponse",
"OAuthTokenResponse",
),
Expand Down
7 changes: 6 additions & 1 deletion src/globus_sdk/services/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
GlobusNativeAppFlowManager,
)
from .identity_map import IdentityMap
from .response import OAuthDependentTokenResponse, OAuthTokenResponse
from .response import (
GetIdentitiesResponse,
OAuthDependentTokenResponse,
OAuthTokenResponse,
)

__all__ = [
"AuthClient",
Expand All @@ -15,6 +19,7 @@
"IdentityMap",
"GlobusNativeAppFlowManager",
"GlobusAuthorizationCodeFlowManager",
"GetIdentitiesResponse",
"OAuthDependentTokenResponse",
"OAuthTokenResponse",
]
2 changes: 1 addition & 1 deletion src/globus_sdk/services/auth/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_identities(
ids: t.Iterable[UUIDLike] | UUIDLike | None = None,
provision: bool = False,
query_params: dict[str, t.Any] | None = None,
) -> GlobusHTTPResponse:
) -> GetIdentitiesResponse:
r"""
Given ``usernames=<U>`` or (exclusive) ``ids=<I>`` as keyword
arguments, looks up identity information for the set of identities
Expand Down
26 changes: 26 additions & 0 deletions tests/non-pytest/mypy-ignore-tests/get_identities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import uuid

from globus_sdk import AuthClient

zero_id = uuid.UUID(int=0)

# ok usages
ac = AuthClient()
ac.get_identities(ids="foo")
ac.get_identities(ids=zero_id)
ac.get_identities(ids=("foo", "bar"))
ac.get_identities(ids=(zero_id,))
ac.get_identities(usernames="foo,bar")
ac.get_identities(usernames=("foo", "bar"))
ac.get_identities(usernames=("foo", "bar"), provision=True)
ac.get_identities(usernames=("foo", "bar"), query_params={"provision": False})

# bad usage
ac.get_identities(usernames=zero_id) # type: ignore[arg-type]
ac.get_identities(usernames=(zero_id,)) # type: ignore[arg-type]


# test the response object is iterable
res = ac.get_identities(usernames="foo")
for x in res:
print(x)