Skip to content

Commit 3bf7e7e

Browse files
committed
Add missing annotations to pass newer mypy
The newer mypy version fails on ambiguous cases which used to be inferred as safe unions or Any. In one case, an extra `isinstance` runtime check is deemed a more appropriate fix than the alternatives (e.g., type ignore).
1 parent 53fe60a commit 3bf7e7e

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

src/globus_sdk/_internal/lazy_import.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ def _load_statement(self, statement: ast.AST) -> None:
212212
f"'{self.pyi_filename}', '__all__' was not a tuple "
213213
)
214214
for element in statement.value.elts:
215-
if not isinstance(element, ast.Constant):
215+
if not isinstance(element, ast.Constant) or not isinstance(
216+
element.value, str
217+
):
216218
continue
217219
self._all_names.append(element.value)
218220

src/globus_sdk/authorizers/renewing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def __init__(
5757
expires_at: int | None = None,
5858
on_refresh: None | t.Callable[[ResponseT], t.Any] = None,
5959
) -> None:
60-
self._access_token = None
61-
self._access_token_hash = None
60+
self._access_token: str | None = None
61+
self._access_token_hash: str | None = None
6262

6363
log.debug(
6464
"Setting up a RenewingAuthorizer. It will use an "

src/globus_sdk/testing/data/auth/create_child_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from globus_sdk.testing.models import RegisteredResponse, ResponseSet
77

8-
_COMMON_RESPONSE_RECORD = {
8+
_COMMON_RESPONSE_RECORD: dict[str, t.Any] = {
99
"fqdns": [],
1010
"links": {"privacy_policy": None, "terms_and_conditions": None},
1111
"parent_client": None,
@@ -17,12 +17,12 @@
1717
"userinfo_from_effective_identity": True,
1818
}
1919

20-
PUBLIC_CLIENT_RESPONSE_RECORD = {
20+
PUBLIC_CLIENT_RESPONSE_RECORD: dict[str, t.Any] = {
2121
"grant_types": ["authorization_code", "refresh_token"],
2222
**_COMMON_RESPONSE_RECORD,
2323
}
2424

25-
PRIVATE_CLIENT_RESPONSE_RECORD = {
25+
PRIVATE_CLIENT_RESPONSE_RECORD: dict[str, t.Any] = {
2626
"grant_types": [
2727
"authorization_code",
2828
"client_credentials",
@@ -32,7 +32,7 @@
3232
**_COMMON_RESPONSE_RECORD,
3333
}
3434

35-
PUBLIC_CLIENT_REQUEST_ARGS = {
35+
PUBLIC_CLIENT_REQUEST_ARGS: dict[str, t.Any] = {
3636
"name": "FOO",
3737
"visibility": "public",
3838
}

src/globus_sdk/testing/data/auth/create_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from globus_sdk.testing.models import RegisteredResponse, ResponseSet
77

8-
_COMMON_RESPONSE_RECORD = {
8+
_COMMON_RESPONSE_RECORD: dict[str, t.Any] = {
99
"fqdns": [],
1010
"links": {"privacy_policy": None, "terms_and_conditions": None},
1111
"parent_client": None,
@@ -17,12 +17,12 @@
1717
"userinfo_from_effective_identity": True,
1818
}
1919

20-
PUBLIC_CLIENT_RESPONSE_RECORD = {
20+
PUBLIC_CLIENT_RESPONSE_RECORD: dict[str, t.Any] = {
2121
"grant_types": ["authorization_code", "refresh_token"],
2222
**_COMMON_RESPONSE_RECORD,
2323
}
2424

25-
PRIVATE_CLIENT_RESPONSE_RECORD = {
25+
PRIVATE_CLIENT_RESPONSE_RECORD: dict[str, t.Any] = {
2626
"grant_types": [
2727
"authorization_code",
2828
"client_credentials",
@@ -32,7 +32,7 @@
3232
**_COMMON_RESPONSE_RECORD,
3333
}
3434

35-
PUBLIC_CLIENT_REQUEST_ARGS = {
35+
PUBLIC_CLIENT_REQUEST_ARGS: dict[str, t.Any] = {
3636
"name": "FOO",
3737
"project": str(uuid.uuid1()),
3838
}

src/globus_sdk/testing/data/auth/update_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from globus_sdk.testing.models import RegisteredResponse, ResponseSet
77

8-
_COMMON_RESPONSE_RECORD = {
8+
_COMMON_RESPONSE_RECORD: dict[str, t.Any] = {
99
"fqdns": [],
1010
"links": {"privacy_policy": None, "terms_and_conditions": None},
1111
"parent_client": None,
@@ -17,7 +17,7 @@
1717
"userinfo_from_effective_identity": True,
1818
}
1919

20-
PUBLIC_CLIENT_RESPONSE_RECORD = {
20+
PUBLIC_CLIENT_RESPONSE_RECORD: dict[str, t.Any] = {
2121
"client_type": "public_installed_client",
2222
"grant_types": ["authorization_code", "refresh_token"],
2323
**_COMMON_RESPONSE_RECORD,

src/globus_sdk/testing/data/timer/_common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import typing as t
12
import uuid
23

34
TIMER_ID = str(uuid.uuid1())
@@ -49,7 +50,7 @@
4950

5051

5152
FLOW_ID = str(uuid.uuid4())
52-
V2_FLOW_TIMER = {
53+
V2_FLOW_TIMER: dict[str, t.Any] = {
5354
"callback_body": {
5455
"body": {"input_key": "input_value"},
5556
"run_managers": [f"urn:globus:auth:identity:{uuid.uuid4()}"],
@@ -84,7 +85,7 @@
8485

8586
# V1 API data
8687

87-
_transfer_data = {
88+
_transfer_data: dict[str, t.Any] = {
8889
"data": {
8990
"action_id": "15jfdBESgveZQ",
9091
"completion_time": "2022-04-01T19:30:05.973261+00:00",

0 commit comments

Comments
 (0)