8000 [webencodings] Add stubs (#14988) · python/typeshed@b3787bc · GitHub
[go: up one dir, main page]

Skip to content

Commit b3787bc

Browse files
authored
[webencodings] Add stubs (#14988)
1 parent 8bed33f commit b3787bc

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Tests should not be part of the stubs
2+
webencodings.tests

stubs/webencodings/METADATA.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version = "0.5.*"
2+
upstream_repository = "https://github.com/gsnedders/python-webencodings"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import codecs
2+
from collections.abc import Iterable, Iterator
3+
from typing import Final
4+
5+
VERSION: Final[str]
6+
PYTHON_NAMES: Final[dict[str, str]]
7+
CACHE: dict[str, Encoding]
8+
9+
def ascii_lower(string: str) -> str: ...
10+
def lookup(label: str) -> Encoding | None: ...
11+
12+
class Encoding:
13+
name: str
14+
codec_info: codecs.CodecInfo
15+
def __init__(self, name: str, codec_info: codecs.CodecInfo) -> None: ...
16+
17+
UTF8: Final[Encoding]
18+
19+
def decode(input: bytes | bytearray, fallback_encoding: str | Encoding, errors: str = "replace") -> tuple[str, Encoding]: ...
20+
def encode(input: str, encoding: str | Encoding = ..., errors: str = "strict") -> bytes: ...
21+
def iter_decode(
22+
input: Iterable[bytes | bytearray], fallback_encoding: str | Encoding, errors: str = "replace"
23+
) -> tuple[Iterator[Encoding | str], Encoding]: ...
24+
def iter_encode(input: Iterable[str], encoding: str | Encoding = ..., errors: str = "strict") -> Iterator[bytes]: ...
25+
26+
class IncrementalDecoder:
27+
encoding: Encoding | None
28+
def __init__(self, fallback_encoding: str | Encoding, errors: str = "replace") -> None: ...
29+
def decode(self, input: bytes | bytearray, final: bool = False) -> str: ...
30+
31+
class IncrementalEncoder:
32+
encode: bytes
33+
def __init__(self, encoding: str | Encoding = ..., errors: str = "strict") -> None: ...
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from typing import Final
2+
3+
LABELS: Final[dict[str, str]]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from typing import AnyStr
2+
from urllib.request import Request
3+
4+
def assert_lower(string: AnyStr) -> AnyStr: ...
5+
def generate(url: str | Request) -> str: ...
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import codecs
2+
from _codecs import _CharMap
3+
from _typeshed import ReadableBuffer
4+
from typing import Final
5+
6+
class Codec(codecs.Codec):
7+
def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ...
8+
def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ...
9+
10+
class IncrementalEncoder(codecs.IncrementalEncoder):
11+
def encode(self, input: str, final: bool = False) -> bytes: ...
12+
13+
class IncrementalDecoder(codecs.IncrementalDecoder):
14+
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ...
15+
16+
class StreamWriter(Codec, codecs.StreamWriter): ...
17+
class StreamReader(Codec, codecs.StreamReader): ...
18+
19+
codec_info: Final[codecs.CodecInfo]
20+
decoding_table: Final[str]
21+
encoding_table: Final[_CharMap]

0 commit comments

Comments
 (0)
0