Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6515b2

Browse files
committed
mypy fixes
1 parent f08c576 commit e6515b2

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

auth0/authentication/async_token_verifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def _fetch_key(self, key_id=None):
4040
key_id (str): The key's key id."""
4141
return await self._fetcher.get_key(key_id)
4242

43-
async def verify_signature(self, token):
43+
async def verify_signature(self, token) -> dict[str, Any]:
4444
"""Verifies the signature of the given JSON web token.
4545
4646
Args:

auth0/authentication/client_authentication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
def create_client_assertion_jwt(
1111
domain: str,
1212
client_id: str,
13-
client_assertion_signing_key: str | None,
13+
client_assertion_signing_key: str,
1414
client_assertion_signing_alg: str | None,
1515
) -> str:
1616
"""Creates a JWT for the client_assertion field.
1717
1818
Args:
1919
domain (str): The domain of your Auth0 tenant
2020
client_id (str): Your application's client ID
21-
client_assertion_signing_key (str, optional): Private key used to sign the client assertion JWT
21+
client_assertion_signing_key (str): Private key used to sign the client assertion JWT
2222
client_assertion_signing_alg (str, optional): Algorithm used to sign the client assertion JWT (defaults to 'RS256')
2323
2424
Returns:

auth0/authentication/token_verifier.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, algorithm: str) -> None:
3939
raise ValueError("algorithm must be specified.")
4040
self._algorithm = algorithm
4141

42-
def _fetch_key(self, key_id: str | None = None) -> str | RSAPublicKey:
42+
def _fetch_key(self, key_id: str) -> str | RSAPublicKey:
4343
"""Obtains the key associated to the given key id.
4444
Must be implemented by subclasses.
4545
@@ -111,6 +111,8 @@ def verify_signature(self, token: str) -> dict[str, Any]:
111111
or the token's signature doesn't match the calculated one.
112112
"""
113113
kid = self._get_kid(token)
114+
if kid is None:
115+
kid = ""
114116
secret_or_certificate = self._fetch_key(key_id=kid)
115117

116118
return self._decode_jwt(token, secret_or_certificate) # type: ignore[arg-type]
@@ -128,7 +130,7 @@ def __init__(self, shared_secret: str, algorithm: str = "HS256") -> None:
128130
super().__init__(algorithm)
129131
self._shared_secret = shared_secret
130132

131-
def _fetch_key(self, key_id: str | None = None) -> str:
133+
def _fetch_key(self, key_id: str = "") -> str:
132134
return self._shared_secret
133135

134136

auth0/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def _calculate_wait(self, attempt: int) -> int:
255255
wait = max(self.MIN_REQUEST_RETRY_DELAY(), wait)
256256

257257
self._metrics["retries"] = attempt
258-
self._metrics["backoff"].append(wait)
258+
self._metrics["backoff"].append(wait) # type: ignore[attr-defined]
259259

260260
return wait
261261

auth0/rest_async.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: disable-error-code=override
21
from __future__ import annotations
32

43
import asyncio
@@ -115,8 +114,8 @@ async def post(
115114
async def file_post(
116115
self,
117116
url: str,
118-
data: dict[str, Any] | None = None,
119-
files: dict[str, Any] | None = None,
117+
data: dict[str, Any],
118+
files: dict[str, Any],
120119
) -> Any:
121120
headers = self.base_headers.copy()
122121
headers.pop("Content-Type", None)

mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ ignore_errors = True
66

77
[mypy-auth0.management.*]
88
ignore_errors = True
9+
10+
[mypy-auth0.rest_async]
11+
disable_error_code=override
12+
13+
[mypy-auth0.authentication.async_token_verifier]
14+
disable_error_code=override, misc, attr-defined

0 commit comments

Comments
 (0)