Skip to content

Commit cda115c

Browse files
committed
feat: localize library type stubs
1 parent e942359 commit cda115c

File tree

6 files changed

+203
-0
lines changed

6 files changed

+203
-0
lines changed

src/itsdangerous.pyi

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3.9
2+
# Copyright (C) 2020-2025 All rights reserved.
3+
# FILENAME: ~~/src/itsdangerous.pyi
4+
# VERSION: 1.0.2
5+
# CREATED: 2025-03-21 15:43
6+
# AUTHOR: Sitt Guruvanich <aekazitt+github@gmail.com>
7+
# DESCRIPTION: https://mypy.readthedocs.io/en/stable/stubs.html
8+
#
9+
# HISTORY:
10+
# *************************************************************
11+
"""Stub file containing a skeleton of the public interface of `itsdangerous` library"""
12+
13+
from abc import ABCMeta
14+
from collections.abc import Iterable
15+
from typing import Any, Generic, Protocol, TYPE_CHECKING, Union
16+
from typing_extensions import TypeVar
17+
18+
class BadData(Exception, metaclass=ABCMeta): ...
19+
class BadSignature(BadData, metaclass=ABCMeta): ...
20+
class BadTimeSignature(BadSignature, metaclass=ABCMeta): ...
21+
class SignatureExpired(BadTimeSignature, metaclass=ABCMeta): ...
22+
23+
if TYPE_CHECKING:
24+
_TSerialized = TypeVar(
25+
"_TSerialized", bound=Union[str, bytes], default=Union[str, bytes], covariant=True
26+
)
27+
else:
28+
_TSerialized = TypeVar("_TSerialized", bound=Union[str, bytes], covariant=True)
29+
30+
class _PDataSerializer(Protocol[_TSerialized], metaclass=ABCMeta): ...
31+
32+
class Serializer(Generic[_TSerialized], metaclass=ABCMeta):
33+
def __init__(
34+
self: Serializer[str],
35+
secret_key: str | bytes | Iterable[str] | Iterable[bytes],
36+
salt: str | bytes | None = b"itsdangerous",
37+
serializer: None | _PDataSerializer[str] = None,
38+
serializer_kwargs: dict[str, Any] | None = None,
39+
signer: type[Signer] | None = None,
40+
signer_kwargs: dict[str, Any] | None = None,
41+
fallback_signers: list[dict[str, Any] | tuple[type[Signer], dict[str, Any]] | type[Signer]]
42+
| None = None,
43+
): ...
44+
def dumps(self, obj: Any, salt: str | bytes | None = None) -> _TSerialized: ...
45+
def loads(self, s: str | bytes, salt: str | bytes | None = None, **kwargs: Any) -> Any: ...
46+
47+
class Signer(metaclass=ABCMeta): ...
48+
class TimedSerializer(Serializer[_TSerialized], metaclass=ABCMeta): ...
49+
class URLSafeSerializerMixin(Serializer[str], metaclass=ABCMeta): ...
50+
class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer[str], metaclass=ABCMeta): ...

src/pydantic.pyi

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3.9
2+
# Copyright (C) 2020-2025 All rights reserved.
3+
# FILENAME: ~~/src/pydantic.pyi
4+
# VERSION: 1.0.2
5+
# CREATED: 2025-03-21 15:43
6+
# AUTHOR: Sitt Guruvanich <aekazitt+github@gmail.com>
7+
# DESCRIPTION: https://mypy.readthedocs.io/en/stable/stubs.html
8+
#
9+
# HISTORY:
10+
# *************************************************************
11+
"""Stub file containing a skeleton of the public interface of `pydantic` library"""
12+
13+
from abc import ABCMeta
14+
from typing import Any, Literal, Generator, Mapping, Set, Tuple, TypeAlias, Union
15+
from typing_extensions import Annotated, Self
16+
17+
class BaseModel(metaclass=ABCMeta):
18+
def __iter__(self) -> TupleGenerator: ...
19+
def model_dump(
20+
self,
21+
*,
22+
mode: Literal["json", "python"] | str = "python",
23+
include: IncEx | None = None,
24+
exclude: IncEx | None = None,
25+
context: Any | None = None,
26+
by_alias: bool = False,
27+
exclude_unset: bool = False,
28+
exclude_defaults: bool = False,
29+
exclude_none: bool = False,
30+
round_trip: bool = False,
31+
warnings: bool | Literal["none", "warn", "error"] = True,
32+
serialize_as_any: bool = False,
33+
) -> dict[str, Any]: ...
34+
@classmethod
35+
def model_validate_json(
36+
cls,
37+
json_data: str | bytes | bytearray,
38+
*,
39+
strict: bool | None = None,
40+
context: Any | None = None,
41+
) -> Self: ...
42+
43+
IncEx: TypeAlias = Union[
44+
Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]]
45+
]
46+
StrictBool = Annotated[bool, ...]
47+
StrictInt = Annotated[int, ...]
48+
StrictStr = Annotated[str, ...]
49+
TupleGenerator: TypeAlias = Generator[Tuple[str, Any], None, None]
50+
51+
class ValidationError(ValueError, metaclass=ABCMeta): ...
52+
53+
def create_model(model_name: str) -> type[BaseModel]: ...
54+
def model_validator(*, mode: Literal["wrap", "before", "after"]) -> Any: ...

src/pydantic_settings.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python3.9
2+
# Copyright (C) 2020-2025 All rights reserved.
3+
# FILENAME: ~~/src/pydantic_settings.pyi
4+
# VERSION: 1.0.2
5+
# CREATED: 2025-03-21 15:43
6+
# AUTHOR: Sitt Guruvanich <aekazitt+github@gmail.com>
7+
# DESCRIPTION: https://mypy.readthedocs.io/en/stable/stubs.html
8+
#
9+
# HISTORY:
10+
# *************************************************************
11+
"""Stub file containing a skeleton of the public interface of `pydantic_settings` library"""
12+
13+
from abc import ABCMeta
14+
from pydantic import BaseModel
15+
16+
class BaseSettings(BaseModel, metaclass=ABCMeta): ...

src/starlette/datastructures.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3.9
2+
# Copyright (C) 2020-2025 All rights reserved.
3+
# FILENAME: ~~/src/starlette/datastructures.pyi
4+
# VERSION: 1.0.2
5+
# CREATED: 2025-03-21 15:43
6+
# AUTHOR: Sitt Guruvanich <aekazitt+github@gmail.com>
7+
# DESCRIPTION: https://mypy.readthedocs.io/en/stable/stubs.html
8+
#
9+
# HISTORY:
10+
# *************************************************************
11+
"""Stub file containing a skeleton of the public interface of `starlette.datastructures` module"""
12+
13+
from abc import ABCMeta
14+
from typing import Mapping
15+
16+
class Headers(Mapping[str, str], metaclass=ABCMeta): ...
17+
class MutableHeaders(Headers, metaclass=ABCMeta): ...
18+
class UploadFile(metaclass=ABCMeta): ...

src/starlette/requests.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python3.9
2+
# Copyright (C) 2020-2025 All rights reserved.
3+
# FILENAME: ~~/src/starlette/requests.pyi
4+
# VERSION: 1.0.2
5+
# CREATED: 2025-03-21 15:43
6+
# AUTHOR: Sitt Guruvanich <aekazitt+github@gmail.com>
7+
# DESCRIPTION: https://mypy.readthedocs.io/en/stable/stubs.html
8+
#
9+
# HISTORY:
10+
# *************************************************************
11+
"""Stub file containing a skeleton of the public interface of `starlette.requests` module"""
12+
13+
from abc import ABCMeta
14+
from typing import Any, Dict, Mapping
15+
16+
from starlette.datastructures import MutableHeaders
17+
18+
class Request(Mapping[str, Any], metaclass=ABCMeta):
19+
async def body(self) -> bytes: ...
20+
@property
21+
def cookies(self) -> Dict[str, str]: ...
22+
@property
23+
def headers(self) -> MutableHeaders: ...

src/starlette/responses.pyi

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3.9
2+
# Copyright (C) 2020-2025 All rights reserved.
3+
# FILENAME: ~~/src/starlette/responses.pyi
4+
# VERSION: 1.0.2
5+
# CREATED: 2025-03-21 15:43
6+
# AUTHOR: Sitt Guruvanich <aekazitt+github@gmail.com>
7+
# DESCRIPTION: https://mypy.readthedocs.io/en/stable/stubs.html
8+
#
9+
# HISTORY:
10+
# *************************************************************
11+
"""Stub file containing a skeleton of the public interface of `starlette.responses` module"""
12+
13+
from abc import ABCMeta, abstractmethod
14+
from datetime import datetime
15+
from typing import Any, Literal, Mapping
16+
17+
class HTTPConnection(Mapping[str, Any], metaclass=ABCMeta): ...
18+
19+
class Response(HTTPConnection, metaclass=ABCMeta):
20+
@abstractmethod
21+
def delete_cookie(
22+
self,
23+
key: str,
24+
path: str = "/",
25+
domain: str | None = None,
26+
secure: bool = False,
27+
httponly: bool = False,
28+
samesite: Literal["lax", "strict", "none"] | None = "lax",
29+
) -> None: ...
30+
@abstractmethod
31+
def set_cookie(
32+
self,
33+
key: str,
34+
value: str = "",
35+
max_age: int | None = None,
36+
expires: datetime | str | int | None = None,
37+
path: str | None = "/",
38+
domain: str | None = None,
39+
secure: bool = False,
40+
httponly: bool = False,
41+
samesite: Literal["lax", "strict", "none"] | None = "lax",
42+
) -> None: ...

0 commit comments

Comments
 (0)