Skip to content

Commit 213eb33

Browse files
fix(event-handler): replace Optional[X] and Dict[X] with modern syntax in swagger_ui/oauth2.py
- Optional[str] -> str | None - Dict[str, str] -> dict[str, str] - Remove unused imports: Dict, Optional from typing Part of #8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
1 parent 53b7e87 commit 213eb33

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • aws_lambda_powertools/event_handler/openapi/swagger_ui

aws_lambda_powertools/event_handler/openapi/swagger_ui/oauth2.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ruff: noqa: E501 FA100
22
import warnings
3-
from typing import Dict, Optional, Sequence
3+
from typing import Sequence
44

55
from pydantic import BaseModel, Field, field_validator
66

@@ -17,14 +17,14 @@ class OAuth2Config(BaseModel):
1717
"""
1818

1919
# The client ID for the OAuth2 application
20-
clientId: Optional[str] = Field(alias="client_id", default=None)
20+
clientId: str | None = Field(alias="client_id", default=None)
2121

2222
# The client secret for the OAuth2 application. This is sensitive information and requires the explicit presence
2323
# of the POWERTOOLS_DEV environment variable.
24-
clientSecret: Optional[str] = Field(alias="client_secret", default=None)
24+
clientSecret: str | None = Field(alias="client_secret", default=None)
2525

2626
# The realm in which the OAuth2 application is registered. Optional.
27-
realm: Optional[str] = Field(default=None)
27+
realm: str | None = Field(default=None)
2828

2929
# The name of the OAuth2 application
3030
appName: str = Field(alias="app_name")
@@ -33,7 +33,7 @@ class OAuth2Config(BaseModel):
3333
scopes: Sequence[str] = Field(default=[])
3434

3535
# Additional query string parameters to be included in the OAuth2 request. Defaults to an empty dictionary.
36-
additionalQueryStringParams: Dict[str, str] = Field(alias="additional_query_string_params", default={})
36+
additionalQueryStringParams: dict[str, str] = Field(alias="additional_query_string_params", default={})
3737

3838
# Whether to use basic authentication with the access code grant type. Defaults to False.
3939
useBasicAuthenticationWithAccessCodeGrant: bool = Field(
@@ -47,7 +47,7 @@ class OAuth2Config(BaseModel):
4747
model_config = MODEL_CONFIG_ALLOW
4848

4949
@field_validator("clientSecret")
50-
def client_secret_only_on_dev(cls, v: Optional[str]) -> Optional[str]:
50+
def client_secret_only_on_dev(cls, v: str | None) -> str | None:
5151
if not v:
5252
return None
5353

0 commit comments

Comments
 (0)