Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fixed
-----

- The type of ``scope_requirements`` in the init signature for ``ClientApp``
has been expanded to ``typing.Mapping`` to match other locations where a
``scope_requirements`` mapping is accepted. (:pr:`NUMBER`)
2 changes: 1 addition & 1 deletion src/globus_sdk/globus_app/client_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
client_id: uuid.UUID | str | None = None,
client_secret: str | None = None,
scope_requirements: (
dict[str, str | Scope | t.Iterable[str | Scope]] | None
t.Mapping[str, str | Scope | t.Iterable[str | Scope]] | None
) = None,
config: GlobusAppConfig = DEFAULT_CONFIG,
) -> None:
Expand Down
32 changes: 29 additions & 3 deletions tests/non-pytest/mypy-ignore-tests/app_scope_requirements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from globus_sdk import UserApp
from types import MappingProxyType

from globus_sdk import ClientApp, UserApp

my_user_app = UserApp("...", client_id="...")
my_client_app = ClientApp("...", client_id="...", client_secret="...")

# declare scope data in the form of a subtype of the
# `str | Scope | t.Iterable[str | Scope]` (`list[str]`) indexed in a dict,
Expand All @@ -9,5 +14,26 @@
# `dict[str, str | Scope | t.Iterable[str | Scope]]` which will reject the input
# type because `dict` is a mutable container, and therefore invariant
scopes: dict[str, list[str]] = {"foo": ["bar"]}
my_app = UserApp("...", client_id="...")
my_app.add_scope_requirements(scopes)
my_user_app.add_scope_requirements(scopes)
my_client_app.add_scope_requirements(scopes)

# a mapping proxy is an immutable mapping (proxy) and should be accepted by apps as well
# meaning that any mapping is fine, not just `dict` specifically (or MutableMapping)
my_user_app.add_scope_requirements(MappingProxyType(scopes))
my_client_app.add_scope_requirements(MappingProxyType(scopes))


# both of the above tests repeated, but now on init
my_user_app = UserApp("...", client_id="...", scope_requirements=scopes)
my_user_app = UserApp(
"...", client_id="...", scope_requirements=MappingProxyType(scopes)
)
my_client_app = ClientApp(
"...", client_id="...", client_secret="...", scope_requirements=scopes
)
my_client_app = ClientApp(
"...",
client_id="...",
client_secret="...",
scope_requirements=MappingProxyType(scopes),
)