Improve Authlib (#13801)

This commit is contained in:
Semyon Moroz
2025-04-07 16:34:05 +04:00
committed by GitHub
parent 5e3e056421
commit e26a15f983
10 changed files with 70 additions and 55 deletions
+7 -3
View File
@@ -1,4 +1,8 @@
from .consts import homepage, version
from typing import Final
__version__ = version
__homepage__ = homepage
from .consts import author, homepage, version
__version__: Final = version
__homepage__: Final = homepage
__author__: Final = author
__license__: Final = "BSD-3-Clause"
+26 -10
View File
@@ -1,10 +1,26 @@
def to_bytes(x, charset: str = "utf-8", errors: str = "strict") -> bytes | None: ...
def to_unicode(x, charset: str = "utf-8", errors: str = "strict") -> str | None: ...
def to_native(x, encoding: str = "ascii"): ...
def json_loads(s): ...
def json_dumps(data, ensure_ascii: bool = False): ...
def urlsafe_b64decode(s): ...
def urlsafe_b64encode(s): ...
def base64_to_int(s): ...
def int_to_base64(num): ...
def json_b64encode(text): ...
from _typeshed import ReadableBuffer
from collections.abc import Iterable
from typing import Any, SupportsBytes, SupportsIndex, overload
@overload
def to_bytes(x: None, charset: str = "utf-8", errors: str = "strict") -> None: ...
@overload
def to_bytes(
x: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer,
charset: str = "utf-8",
errors: str = "strict",
) -> bytes: ...
@overload
def to_unicode(x: None, charset: str = "utf-8", errors: str = "strict") -> None: ...
@overload
def to_unicode(x: object, charset: str = "utf-8", errors: str = "strict") -> str: ...
def to_native(x: str | bytes, encoding: str = "ascii") -> str: ...
def json_loads(s: str | bytes | bytearray) -> Any: ... # returns json.loads()
def json_dumps(data: Any, ensure_ascii: bool = False) -> str: ... # data pass to json.dumps()
def urlsafe_b64decode(s: bytes) -> bytes: ...
def urlsafe_b64encode(s: ReadableBuffer) -> bytes: ...
def base64_to_int(s: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer) -> int: ...
def int_to_base64(num: int) -> str: ...
def json_b64encode(
text: str | bytes | float | Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer,
) -> bytes: ...
+11 -16
View File
@@ -1,26 +1,21 @@
from _typeshed import Incomplete
from typing import Literal
class AuthlibBaseError(Exception):
error: Incomplete
error: str | None
description: str
uri: Incomplete
def __init__(
self, error: Incomplete | None = None, description: Incomplete | None = None, uri: Incomplete | None = None
) -> None: ...
uri: str | None
def __init__(self, error: str | None = None, description: str | None = None, uri: str | None = None) -> None: ...
class AuthlibHTTPError(AuthlibBaseError):
status_code: int
def __init__(
self,
error: Incomplete | None = None,
description: Incomplete | None = None,
uri: Incomplete | None = None,
status_code: Incomplete | None = None,
self, error: str | None = None, description: str | None = None, uri: str | None = None, status_code: int | None = None
) -> None: ...
def get_error_description(self): ...
def get_body(self): ...
def get_headers(self): ...
uri: Incomplete
def __call__(self, uri: Incomplete | None = None): ...
def get_error_description(self) -> str: ...
def get_body(self) -> list[tuple[Literal["error", "error_description", "error_uri"], str | None]]: ...
def get_headers(self) -> list[tuple[str, str]]: ...
def __call__(
self, uri: str | None = None
) -> tuple[int, dict[Literal["error", "error_description", "error_uri"], str | None], list[tuple[str, str]]]: ...
class ContinueIteration(AuthlibBaseError): ...
+3 -1
View File
@@ -1,4 +1,6 @@
UNICODE_ASCII_CHARACTER_SET: str
from typing import Final
UNICODE_ASCII_CHARACTER_SET: Final[str]
def generate_token(length: int = 30, chars: str = ...) -> str: ...
def is_secure_transport(uri: str) -> bool: ...
+4 -4
View File
@@ -1,10 +1,10 @@
from collections.abc import Collection
from re import Pattern
from typing import Final
from typing_extensions import TypeAlias
always_safe: str
urlencoded: Collection[str]
INVALID_HEX_PATTERN: Pattern[str]
always_safe: Final[str]
urlencoded: Final[set[str]]
INVALID_HEX_PATTERN: Final[Pattern[str]]
_ExplodedQueryString: TypeAlias = list[tuple[str, str]]
+7 -7
View File
@@ -1,8 +1,8 @@
from _typeshed import Incomplete
from typing import Final
name: str
version: str
author: str
homepage: str
default_user_agent: Incomplete
default_json_headers: Incomplete
name: Final[str]
version: Final[str]
author: Final[str]
homepage: Final[str]
default_user_agent: Final[str]
default_json_headers: Final[list[tuple[str, str]]]
+1 -5
View File
@@ -1,7 +1,3 @@
from _typeshed import Incomplete
class AuthlibDeprecationWarning(DeprecationWarning): ...
def deprecate(
message, version: Incomplete | None = None, link_uid: Incomplete | None = None, link_file: Incomplete | None = None
) -> None: ...
def deprecate(message: str, version: str | None = None, link_uid: str | None = None, link_file: str | None = None) -> None: ...
+2 -4
View File
@@ -1,5 +1,3 @@
from _typeshed import Incomplete
from .errors import JoseError as JoseError
from .rfc7515 import (
JsonWebSignature as JsonWebSignature,
@@ -18,6 +16,8 @@ from .rfc7518 import ECKey as ECKey, OctKey as OctKey, RSAKey as RSAKey
from .rfc7519 import BaseClaims as BaseClaims, JsonWebToken as JsonWebToken, JWTClaims as JWTClaims
from .rfc8037 import OKPKey as OKPKey
jwt: JsonWebToken
__all__ = [
"JoseError",
"JsonWebSignature",
@@ -40,5 +40,3 @@ __all__ = [
"JWTClaims",
"jwt",
]
jwt: Incomplete
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
class BaseClaims(dict[str, object]):
REGISTERED_CLAIMS: Incomplete
REGISTERED_CLAIMS: list[str]
header: Incomplete
options: Incomplete
params: Incomplete
@@ -10,7 +10,7 @@ class BaseClaims(dict[str, object]):
def get_registered_claims(self): ...
class JWTClaims(BaseClaims):
REGISTERED_CLAIMS: Incomplete
REGISTERED_CLAIMS: list[str]
def validate(self, now: Incomplete | None = None, leeway: int = 0) -> None: ...
def validate_iss(self) -> None: ...
def validate_sub(self) -> None: ...
+7 -3
View File
@@ -1,3 +1,7 @@
def extract_header(header_segment, error_cls): ...
def extract_segment(segment, error_cls, name: str = "payload"): ...
def ensure_dict(s, structure_name): ...
from _typeshed import Incomplete
from authlib.common.errors import AuthlibBaseError
def extract_header(header_segment: bytes, error_cls: AuthlibBaseError) -> dict[Incomplete, Incomplete]: ...
def extract_segment(segment: bytes, error_cls: AuthlibBaseError, name: str = "payload") -> bytes: ...
def ensure_dict(s: object, structure_name: str) -> dict[Incomplete, Incomplete]: ...