Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit eecbf37

Browse files
committed
Many updates
1 parent 48c2cd6 commit eecbf37

20 files changed

+1251
-1083
lines changed

.github/workflows/build.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ jobs:
88
matrix:
99
os: [ubuntu-latest]
1010
os-name: [Ubuntu]
11-
python-version: ["3.8", "3.9", "3.10", "3.11"]
11+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1212
# we do not want a large number of windows and macos builds, so
1313
# enumerate them explicitly
1414
include:
1515
- os: windows-latest
1616
os-name: Windows
17-
python-version: 3.11
17+
python-version: "3.13"
1818
- os: macos-latest
1919
os-name: MacOS
20-
python-version: 3.11
20+
python-version: "3.13"
2121

2222
name: "Test py${{ matrix.python-version }} on ${{ matrix.os-name }}"
2323
runs-on: ${{ matrix.os }}

.pre-commit-config.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
@@ -12,31 +12,31 @@ repos:
1212
- id: check-added-large-files
1313

1414
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.10.1
15+
rev: v3.19.0
1616
hooks:
1717
- id: pyupgrade
1818
args:
19-
- "--py38-plus"
19+
- "--py39-plus"
2020

2121
- repo: https://github.com/python-jsonschema/check-jsonschema
22-
rev: 0.24.1
22+
rev: 0.30.0
2323
hooks:
2424
- id: check-github-workflows
2525
- id: check-dependabot
2626

2727
- repo: https://github.com/psf/black-pre-commit-mirror
28-
rev: 23.7.0
28+
rev: 24.10.0
2929
hooks:
3030
- id: black-jupyter
3131
- id: black
3232

3333
- repo: https://github.com/pycqa/isort
34-
rev: 5.12.0
34+
rev: 5.13.2
3535
hooks:
3636
- id: isort
3737

3838
- repo: https://github.com/PyCQA/flake8
39-
rev: 6.1.0
39+
rev: 7.1.1
4040
hooks:
4141
- id: flake8
4242
additional_dependencies: ["flake8-bugbear==23.7.10"]

globus_automate_client/action_client.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import uuid
3-
from typing import Any, Dict, Iterable, List, Mapping, Optional, Type, TypeVar, Union
3+
from collections.abc import Iterable, Mapping
4+
from typing import Any, Optional, TypeVar, Union
45
from urllib.parse import quote, urlparse
56

67
from globus_sdk import BaseClient, GlobusHTTPResponse
@@ -76,7 +77,7 @@ def run(
7677
manage_by: Optional[Iterable[str]] = None,
7778
monitor_by: Optional[Iterable[str]] = None,
7879
label: Optional[str] = None,
79-
tags: Optional[List[str]] = None,
80+
tags: Optional[list[str]] = None,
8081
force_path: Optional[str] = None,
8182
**kwargs,
8283
) -> GlobusHTTPResponse:
@@ -203,7 +204,7 @@ def log(
203204

204205
# *reverse_order* MUST BE None to prevent reversing the sort order.
205206
# Any other value, including False, will reverse the sort order.
206-
params: Dict[str, Union[int, str, bool, None]] = {
207+
params: dict[str, Union[int, str, bool, None]] = {
207208
"reverse_order": True if reverse_order else None,
208209
"limit": limit,
209210
}
@@ -215,7 +216,7 @@ def log(
215216

216217
@classmethod
217218
def new_client(
218-
cls: Type[_ActionClient],
219+
cls: type[_ActionClient],
219220
action_url: str,
220221
authorizer: Optional[GlobusAuthorizer],
221222
http_timeout: int = 10,

globus_automate_client/cli/actions.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import functools
2-
from typing import List
32

43
import typer
54

@@ -71,14 +70,14 @@ def action_run(
7170
None,
7271
help="An identifier to associate with this Action invocation request",
7372
),
74-
manage_by: List[str] = typer.Option(
73+
manage_by: list[str] = typer.Option(
7574
None,
7675
help="A principal which may change the execution of the Action. The principal "
7776
"is the user's or group's UUID prefixed with either 'urn:globus:groups:id:' "
7877
"or 'urn:globus:auth:identity:' [repeatable]",
7978
callback=principal_validator,
8079
),
81-
monitor_by: List[str] = typer.Option(
80+
monitor_by: list[str] = typer.Option(
8281
None,
8382
help="A principal which may view the state of the Action. The principal "
8483
"is the user's or group's UUID prefixed with either 'urn:globus:groups:id:' "

globus_automate_client/cli/auth.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import platform
66
import sys
77
from json import JSONDecodeError
8-
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Union, cast
8+
from typing import Any, Callable, NamedTuple, Optional, Union, cast
99

1010
import click
1111
import typer
@@ -55,10 +55,10 @@ class TokenSet(NamedTuple):
5555
# there isn't a matching dependent scope, that means we need to prompt for consent
5656
# again. If there is a matching full-scope-string in `dependent_scopes`, then we're
5757
# OK to use the token from looking up that base scope.
58-
dependent_scopes: Set[str]
58+
dependent_scopes: set[str]
5959

6060

61-
TokensInTokenCache = Dict[str, Union[TokenSet, Dict[str, TokenSet]]]
61+
TokensInTokenCache = dict[str, Union[TokenSet, dict[str, TokenSet]]]
6262

6363

6464
class TokenCache:
@@ -81,7 +81,7 @@ def tokens_for_environment(self):
8181
return self.tokens
8282
environ_cache_key = TokenCache._environment_prefix + environ
8383
if environ_cache_key not in self.tokens:
84-
self.tokens[environ_cache_key]: Dict[str, TokenSet] = {}
84+
self.tokens[environ_cache_key]: dict[str, TokenSet] = {}
8585
return self.tokens[environ_cache_key]
8686

8787
def set_tokens(self, scope: str, tokens: TokenSet) -> TokenSet:
@@ -115,7 +115,7 @@ def get_tokens(self, scope: str) -> Optional[TokenSet]:
115115
return self.tokens_for_environment.get(scope)
116116

117117
@staticmethod
118-
def _deserialize_from_file(file_tokens: Dict[str, Any]) -> TokensInTokenCache:
118+
def _deserialize_from_file(file_tokens: dict[str, Any]) -> TokensInTokenCache:
119119
deserialized: TokensInTokenCache = {}
120120
for k, v in file_tokens.items():
121121
if k.startswith(TokenCache._environment_prefix):
@@ -142,8 +142,8 @@ def load_tokens(self):
142142
)
143143

144144
@staticmethod
145-
def _make_jsonable(tokens) -> Dict[str, Any]:
146-
serialized: Dict[str, Any] = {}
145+
def _make_jsonable(tokens) -> dict[str, Any]:
146+
serialized: dict[str, Any] = {}
147147
for k, v in tokens.items():
148148
if isinstance(v, TokenSet):
149149
v = v._asdict()
@@ -194,10 +194,10 @@ def clear_tokens(
194194
self.modified = True
195195

196196
def update_from_oauth_token_response(
197-
self, token_response: OAuthTokenResponse, original_scopes: Set[str]
198-
) -> Dict[str, TokenSet]:
197+
self, token_response: OAuthTokenResponse, original_scopes: set[str]
198+
) -> dict[str, TokenSet]:
199199
by_scopes = token_response.by_scopes
200-
token_sets: Dict[str, TokenSet] = {}
200+
token_sets: dict[str, TokenSet] = {}
201201
for scope in by_scopes:
202202
token_info = by_scopes[scope]
203203
dependent_scopes = {s for s in original_scopes if "[" in s}
@@ -237,7 +237,7 @@ def safeprint(s, err: bool = False):
237237

238238

239239
def _do_login_for_scopes(
240-
native_client: NativeAppAuthClient, scopes: List[str]
240+
native_client: NativeAppAuthClient, scopes: list[str]
241241
) -> OAuthTokenResponse:
242242
label = CLIENT_NAME
243243
host = platform.node()
@@ -269,17 +269,17 @@ def refresh_handler(response: OAuthTokenResponse, *args, **kwargs):
269269

270270

271271
def get_authorizers_for_scopes(
272-
scopes: List[str],
272+
scopes: list[str],
273273
token_store: Optional[Union[pathlib.Path, str]] = None,
274274
client_id: str = CLIENT_ID,
275275
client_name: str = CLIENT_NAME,
276276
no_login: bool = False,
277-
) -> Dict[str, GlobusAuthorizer]:
277+
) -> dict[str, GlobusAuthorizer]:
278278
token_store = token_store or str(DEFAULT_TOKEN_FILE)
279279
token_cache = TokenCache(token_store)
280280
token_cache.load_tokens()
281-
token_sets: Dict[str, TokenSet] = {}
282-
needed_scopes: Set[str] = set()
281+
token_sets: dict[str, TokenSet] = {}
282+
needed_scopes: set[str] = set()
283283
native_client = _get_globus_sdk_native_client(client_id, client_name)
284284

285285
for scope in scopes:
@@ -296,7 +296,7 @@ def get_authorizers_for_scopes(
296296
)
297297
token_sets.update(new_tokens)
298298

299-
authorizers: Dict[str, GlobusAuthorizer] = {}
299+
authorizers: dict[str, GlobusAuthorizer] = {}
300300
for scope, token_set in token_sets.items():
301301
if token_set is not None:
302302
authorizer: Union[RefreshTokenAuthorizer, AccessTokenAuthorizer]
@@ -362,7 +362,7 @@ def revoker(scope: str, token_set: TokenSet) -> bool:
362362

363363
def get_current_user(
364364
no_login: bool = False, token_store: Union[pathlib.Path, str] = DEFAULT_TOKEN_FILE
365-
) -> Optional[Dict[str, Any]]:
365+
) -> Optional[dict[str, Any]]:
366366
"""
367367
When `no_login` is set, returns `None` if not logged in.
368368
"""

globus_automate_client/cli/callbacks.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pathlib
44
import re
55
from errno import ENAMETOOLONG
6-
from typing import AbstractSet, Callable, List, Optional, cast
6+
from typing import AbstractSet, Callable, Optional, cast
77
from urllib.parse import urlparse
88

99
import typer
@@ -38,8 +38,8 @@ def url_validator_callback(url: str) -> str:
3838

3939

4040
def _base_principal_validator(
41-
principals: List[str], *, special_vals: AbstractSet[str] = frozenset()
42-
) -> List[str]:
41+
principals: list[str], *, special_vals: AbstractSet[str] = frozenset()
42+
) -> list[str]:
4343
"""
4444
This validator ensures the principal IDs are valid UUIDs prefixed with valid
4545
Globus ID beginnings. It will optionally determine if a provided principal
@@ -76,16 +76,16 @@ def _base_principal_validator(
7676
return valid_principals
7777

7878

79-
def principal_validator(principals: List[str]) -> List[str]:
79+
def principal_validator(principals: list[str]) -> list[str]:
8080
"""A principal ID needs to be a valid UUID."""
8181

82-
return _base_principal_validator(cast(List[str], principals))
82+
return _base_principal_validator(cast(list[str], principals))
8383

8484

8585
def custom_principal_validator(special_values: AbstractSet[str]) -> Callable:
8686
"""A principal ID needs to be a valid UUID."""
8787

88-
def wrapper(principals: List[str]) -> List[str]:
88+
def wrapper(principals: list[str]) -> list[str]:
8989
return _base_principal_validator(principals, special_vals=special_values)
9090

9191
return wrapper

0 commit comments

Comments
 (0)