Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stubs/webencodings/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tests should not be part of the stubs
webencodings.tests
2 changes: 2 additions & 0 deletions stubs/webencodings/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "0.5.*"
upstream_repository = "https://github.com/SimonSapin/python-webencodings"
33 changes: 33 additions & 0 deletions stubs/webencodings/webencodings/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
3 changes: 3 additions & 0 deletions stubs/webencodings/webencodings/labels.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Final

LABELS: Final[dict[str, str]]
5 changes: 5 additions & 0 deletions stubs/webencodings/webencodings/mklabels.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
21 changes: 21 additions & 0 deletions stubs/webencodings/webencodings/x_user_defined.pyi
Original file line number Diff line number Diff line change
@@ -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]
Loading