Skip to content

Commit b6d9c44

Browse files
author
Max Rabin
committed
Upgrade Python syntax by using Pyupgrade, adding it to Ruff (UP).
1 parent df5a2c9 commit b6d9c44

File tree

27 files changed

+437
-435
lines changed

27 files changed

+437
-435
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ ignore_missing_imports = false
6767

6868
[tool.ruff]
6969
line-length = 120
70-
include = ["examples/**/*.py", "src/**/*.py", "tests/**/*.py", "tests-integ/**/*.py"]
70+
include = ["examples/**/*.py", "src/**/*.py", "tests/**/*.py", "tests_integ/**/*.py"]
7171
exclude = ["**/*.md"]
7272

7373
[tool.ruff.lint]
@@ -79,6 +79,7 @@ select = [
7979
"G", # logging format
8080
"I", # isort
8181
"LOG", # logging
82+
"UP", # pyupgrade
8283
]
8384

8485
[tool.ruff.lint.per-file-ignores]

src/bedrock_agentcore/identity/auth.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import contextvars
55
import logging
66
import os
7+
from collections.abc import Callable
78
from functools import wraps
8-
from typing import Any, Callable, Dict, List, Literal, Optional
9+
from typing import Any, Literal
910

1011
import boto3
1112

@@ -22,14 +23,14 @@ def requires_access_token(
2223
*,
2324
provider_name: str,
2425
into: str = "access_token",
25-
scopes: List[str],
26-
on_auth_url: Optional[Callable[[str], Any]] = None,
26+
scopes: list[str],
27+
on_auth_url: Callable[[str], Any] | None = None,
2728
auth_flow: Literal["M2M", "USER_FEDERATION"],
28-
callback_url: Optional[str] = None,
29+
callback_url: str | None = None,
2930
force_authentication: bool = False,
30-
token_poller: Optional[TokenPoller] = None,
31-
custom_state: Optional[str] = None,
32-
custom_parameters: Optional[Dict[str, str]] = None,
31+
token_poller: TokenPoller | None = None,
32+
custom_state: str | None = None,
33+
custom_parameters: dict[str, str] | None = None,
3334
) -> Callable:
3435
"""Decorator that fetches an OAuth2 access token before calling the decorated function.
3536
@@ -151,7 +152,7 @@ def sync_wrapper(*args: Any, **kwargs: Any) -> Any:
151152
return decorator
152153

153154

154-
def _get_oauth2_callback_url(user_provided_oauth2_callback_url: Optional[str]):
155+
def _get_oauth2_callback_url(user_provided_oauth2_callback_url: str | None):
155156
if user_provided_oauth2_callback_url:
156157
return user_provided_oauth2_callback_url
157158

@@ -184,7 +185,7 @@ async def _set_up_local_auth(client: IdentityClient) -> str:
184185
config = {}
185186
if config_path.exists():
186187
try:
187-
with open(config_path, "r", encoding="utf-8") as file:
188+
with open(config_path, encoding="utf-8") as file:
188189
config = json.load(file) or {}
189190
except Exception:
190191
print("Could not find existing workload identity and user id")

0 commit comments

Comments
 (0)