Skip to content

Commit 5083dbc

Browse files
committed
[IMP] : pre-commit auto fixes
1 parent eaa2167 commit 5083dbc

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exclude: |
22
(?x)
33
# NOT INSTALLABLE ADDONS
4-
^extendable/|
4+
^fastapi_auth_jwt/|
55
# END NOT INSTALLABLE ADDONS
66
# Files and folders generated by bots, to avoid loops
77
^setup/|/static/description/index\.html$|

base_rest_auth_api_key/static/description/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>Base Rest Auth Api Key</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:7c57ea5f8972ccd3fd126f96da0ff252203ec8d51cb0a1f2e4a1b101e730d838
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/18.0/base_rest_auth_api_key"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-base_rest_auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/18.0/base_rest_auth_api_key"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-base_rest_auth_api_key"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This technical addon extend base_rest to add the support for
379379
auth_api_key authentication mechanism into the generated openapi
380380
documentation.</p>

fastapi_auth_jwt/dependencies.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
33

44
import logging
5-
from typing import Annotated, Any, Dict, Optional, Tuple, Union
5+
from typing import Annotated, Any
66

77
from starlette.status import HTTP_401_UNAUTHORIZED
88

@@ -25,11 +25,11 @@
2525
_logger = logging.getLogger(__name__)
2626

2727

28-
Payload = Dict[str, Any]
28+
Payload = dict[str, Any]
2929

3030

3131
def _get_auth_jwt_validator(
32-
validator_name: Union[str, None],
32+
validator_name: str | None,
3333
env: Environment,
3434
) -> AuthJwtValidator:
3535
validator = env["auth.jwt.validator"].sudo()._get_validator_by_name(validator_name)
@@ -39,9 +39,9 @@ def _get_auth_jwt_validator(
3939

4040
def _request_has_authentication(
4141
request: Request,
42-
authorization_header: Optional[str],
42+
authorization_header: str | None,
4343
validator: AuthJwtValidator,
44-
) -> Union[Payload, None]:
44+
) -> Payload | None:
4545
if authorization_header is not None:
4646
return True
4747
if not validator.cookie_enabled:
@@ -52,7 +52,7 @@ def _request_has_authentication(
5252

5353
def _get_jwt_payload(
5454
request: Request,
55-
authorization_header: Optional[str],
55+
authorization_header: str | None,
5656
validator: AuthJwtValidator,
5757
) -> Payload:
5858
"""Obtain and validate the JWT payload from the request authorization header or
@@ -76,9 +76,9 @@ def _get_jwt_payload(
7676
def _get_jwt_payload_and_validator(
7777
request: Request,
7878
response: Response,
79-
authorization_header: Optional[str],
79+
authorization_header: str | None,
8080
validator: AuthJwtValidator,
81-
) -> Tuple[Payload, AuthJwtValidator]:
81+
) -> tuple[Payload, AuthJwtValidator]:
8282
try:
8383
payload = None
8484
exceptions = {}
@@ -117,15 +117,15 @@ def _get_jwt_payload_and_validator(
117117
raise HTTPException(status_code=HTTP_401_UNAUTHORIZED) from e
118118

119119

120-
def auth_jwt_default_validator_name() -> Union[str, None]:
120+
def auth_jwt_default_validator_name() -> str | None:
121121
return None
122122

123123

124124
def auth_jwt_http_header_authorization(
125125
credentials: Annotated[
126-
Optional[HTTPAuthorizationCredentials],
126+
HTTPAuthorizationCredentials | None,
127127
Depends(HTTPBearer(auto_error=False)),
128-
]
128+
],
129129
):
130130
if credentials is None:
131131
return None
@@ -134,7 +134,7 @@ def auth_jwt_http_header_authorization(
134134

135135
class BaseAuthJwt: # noqa: B903
136136
def __init__(
137-
self, validator_name: Optional[str] = None, allow_unauthenticated: bool = False
137+
self, validator_name: str | None = None, allow_unauthenticated: bool = False
138138
):
139139
self.validator_name = validator_name
140140
self.allow_unauthenticated = allow_unauthenticated
@@ -146,18 +146,18 @@ def __call__(
146146
request: Request,
147147
response: Response,
148148
authorization_header: Annotated[
149-
Optional[str],
149+
str | None,
150150
Depends(auth_jwt_http_header_authorization),
151151
],
152152
default_validator_name: Annotated[
153-
Union[str, None],
153+
str | None,
154154
Depends(auth_jwt_default_validator_name),
155155
],
156156
env: Annotated[
157157
Environment,
158158
Depends(odoo_env),
159159
],
160-
) -> Optional[Payload]:
160+
) -> Payload | None:
161161
validator = _get_auth_jwt_validator(
162162
self.validator_name or default_validator_name, env
163163
)
@@ -176,11 +176,11 @@ def __call__(
176176
request: Request,
177177
response: Response,
178178
authorization_header: Annotated[
179-
Optional[str],
179+
str | None,
180180
Depends(auth_jwt_http_header_authorization),
181181
],
182182
default_validator_name: Annotated[
183-
Union[str, None],
183+
str | None,
184184
Depends(auth_jwt_default_validator_name),
185185
],
186186
env: Annotated[
@@ -215,11 +215,11 @@ def __call__(
215215
request: Request,
216216
response: Response,
217217
authorization_header: Annotated[
218-
Optional[str],
218+
str | None,
219219
Depends(auth_jwt_http_header_authorization),
220220
],
221221
default_validator_name: Annotated[
222-
Union[str, None],
222+
str | None,
223223
Depends(auth_jwt_default_validator_name),
224224
],
225225
env: Annotated[

0 commit comments

Comments
 (0)