From 2375446c929df49c55c3054fab30c300c15a3443 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Fri, 7 Nov 2025 13:24:36 +0400 Subject: [PATCH 1/2] [webencodings] Add stubs PyPI: https://pypi.org/project/webencodings/ Source: https://github.com/gsnedders/python-webencodings Stats: https://pypistats.org/packages/webencodings --- .../@tests/stubtest_allowlist.txt | 2 ++ stubs/webencodings/METADATA.toml | 2 ++ stubs/webencodings/webencodings/__init__.pyi | 33 +++++++++++++++++++ stubs/webencodings/webencodings/labels.pyi | 3 ++ stubs/webencodings/webencodings/mklabels.pyi | 5 +++ .../webencodings/x_user_defined.pyi | 21 ++++++++++++ 6 files changed, 66 insertions(+) create mode 100644 stubs/webencodings/@tests/stubtest_allowlist.txt create mode 100644 stubs/webencodings/METADATA.toml create mode 100644 stubs/webencodings/webencodings/__init__.pyi create mode 100644 stubs/webencodings/webencodings/labels.pyi create mode 100644 stubs/webencodings/webencodings/mklabels.pyi create mode 100644 stubs/webencodings/webencodings/x_user_defined.pyi diff --git a/stubs/webencodings/@tests/stubtest_allowlist.txt b/stubs/webencodings/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..a7af9d8760da --- /dev/null +++ b/stubs/webencodings/@tests/stubtest_allowlist.txt @@ -0,0 +1,2 @@ +# Tests should not be part of the stubs +webencodings.tests diff --git a/stubs/webencodings/METADATA.toml b/stubs/webencodings/METADATA.toml new file mode 100644 index 000000000000..6590ee39b503 --- /dev/null +++ b/stubs/webencodings/METADATA.toml @@ -0,0 +1,2 @@ +version = "0.5.*" +upstream_repository = "https://github.com/SimonSapin/python-webencodings" diff --git a/stubs/webencodings/webencodings/__init__.pyi b/stubs/webencodings/webencodings/__init__.pyi new file mode 100644 index 000000000000..c9f078493786 --- /dev/null +++ b/stubs/webencodings/webencodings/__init__.pyi @@ -0,0 +1,33 @@ +import codecs +from collections.abc import Iterable, Iterator +from typing import Final + +VERSION: Final[str] +PYTHON_NAMES: Final[dict[str, str]] +CACHE: dict[str, Encoding] + +def ascii_lower(string: str) -> str: ... +def lookup(label: str) -> Encoding | None: ... + +class Encoding: + name: str + codec_info: codecs.CodecInfo + def __init__(self, name: str, codec_info: codecs.CodecInfo) -> None: ... + +UTF8: Final[Encoding] + +def decode(input: bytes | bytearray, fallback_encoding: str | Encoding, errors: str = "replace") -> tuple[str, Encoding]: ... +def encode(input: str, encoding: str | Encoding = ..., errors: str = "strict") -> bytes: ... +def iter_decode( + input: Iterable[bytes | bytearray], fallback_encoding: str | Encoding, errors: str = "replace" +) -> tuple[Iterator[Encoding | str], Encoding]: ... +def iter_encode(input: Iterable[str], encoding: str | Encoding = ..., errors: str = "strict") -> Iterator[bytes]: ... + +class IncrementalDecoder: + encoding: Encoding | None + def __init__(self, fallback_encoding: str | Encoding, errors: str = "replace") -> None: ... + def decode(self, input: bytes | bytearray, final: bool = False) -> str: ... + +class IncrementalEncoder: + encode: bytes + def __init__(self, encoding: str | Encoding = ..., errors: str = "strict") -> None: ... diff --git a/stubs/webencodings/webencodings/labels.pyi b/stubs/webencodings/webencodings/labels.pyi new file mode 100644 index 000000000000..01deda966843 --- /dev/null +++ b/stubs/webencodings/webencodings/labels.pyi @@ -0,0 +1,3 @@ +from typing import Final + +LABELS: Final[dict[str, str]] diff --git a/stubs/webencodings/webencodings/mklabels.pyi b/stubs/webencodings/webencodings/mklabels.pyi new file mode 100644 index 000000000000..839692415fbd --- /dev/null +++ b/stubs/webencodings/webencodings/mklabels.pyi @@ -0,0 +1,5 @@ +from typing import AnyStr +from urllib.request import Request + +def assert_lower(string: AnyStr) -> AnyStr: ... +def generate(url: str | Request) -> str: ... diff --git a/stubs/webencodings/webencodings/x_user_defined.pyi b/stubs/webencodings/webencodings/x_user_defined.pyi new file mode 100644 index 000000000000..bb67491c8606 --- /dev/null +++ b/stubs/webencodings/webencodings/x_user_defined.pyi @@ -0,0 +1,21 @@ +import codecs +from _codecs import _CharMap +from _typeshed import ReadableBuffer +from typing import Final + +class Codec(codecs.Codec): + def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ... + def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ... + +class IncrementalEncoder(codecs.IncrementalEncoder): + def encode(self, input: str, final: bool = False) -> bytes: ... + +class IncrementalDecoder(codecs.IncrementalDecoder): + def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... + +class StreamWriter(Codec, codecs.StreamWriter): ... +class StreamReader(Codec, codecs.StreamReader): ... + +codec_info: Final[codecs.CodecInfo] +decoding_table: Final[str] +encoding_table: Final[_CharMap] From 7803d1988837fbb230e10ac235fa6ffcf42e1176 Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Fri, 7 Nov 2025 09:31:54 +0000 Subject: [PATCH 2/2] Update stubs/webencodings/METADATA.toml Co-authored-by: Sebastian Rittau --- stubs/webencodings/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/webencodings/METADATA.toml b/stubs/webencodings/METADATA.toml index 6590ee39b503..faf76668a57c 100644 --- a/stubs/webencodings/METADATA.toml +++ b/stubs/webencodings/METADATA.toml @@ -1,2 +1,2 @@ version = "0.5.*" -upstream_repository = "https://github.com/SimonSapin/python-webencodings" +upstream_repository = "https://github.com/gsnedders/python-webencodings"