Add IO protocols to _typeshed (#4230)

This commit is contained in:
Sebastian Rittau
2020-06-14 20:44:48 +02:00
committed by GitHub
parent ef74bee249
commit 51cf2f51b8
21 changed files with 80 additions and 131 deletions

View File

@@ -1,4 +1,5 @@
from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Protocol, Optional
from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Optional
from _typeshed import SupportsReadline
DEFAULTSECT: str
MAX_INTERPOLATION_DEPTH: int
@@ -50,9 +51,6 @@ class MissingSectionHeaderError(ParsingError):
line: Any
def __init__(self, filename: str, lineno: Any, line: Any) -> None: ...
class _Readable(Protocol):
def readline(self) -> str: ...
class RawConfigParser:
_dict: Any
_sections: Dict[Any, Any]
@@ -68,7 +66,7 @@ class RawConfigParser:
def has_section(self, section: str) -> bool: ...
def options(self, section: str) -> List[str]: ...
def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ...
def readfp(self, fp: _Readable, filename: str = ...) -> None: ...
def readfp(self, fp: SupportsReadline[str], filename: str = ...) -> None: ...
def get(self, section: str, option: str) -> str: ...
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
def _get(self, section: str, conv: type, option: str) -> Any: ...

View File

@@ -15,7 +15,7 @@ from io import (
TextIOWrapper, FileIO, BufferedRandom, BufferedReader, BufferedWriter
)
from types import TracebackType, CodeType
from _typeshed import AnyPath, OpenBinaryMode, OpenTextMode, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenBinaryModeReading
from _typeshed import AnyPath, OpenBinaryMode, OpenTextMode, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenBinaryModeReading, SupportsWrite
from typing_extensions import Literal
import sys
@@ -1480,17 +1480,13 @@ else:
def ord(__c: Union[Text, bytes]) -> int: ...
if sys.version_info >= (3,):
class _Writer(Protocol):
def write(self, __s: str) -> Any: ...
def print(
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[str]] = ..., flush: bool = ...
) -> None: ...
else:
class _Writer(Protocol):
def write(self, __s: Any) -> Any: ...
# This is only available after from __future__ import print_function.
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ...
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ...) -> None: ...
_E = TypeVar("_E", contravariant=True)
_M = TypeVar("_M", contravariant=True)

View File

@@ -1,4 +1,5 @@
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Protocol, Type
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Type
from _typeshed import SupportsRead
class JSONDecodeError(ValueError):
def dumps(self, obj: Any) -> str: ...
@@ -43,10 +44,7 @@ def loads(s: Union[Text, bytes],
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
class _Reader(Protocol):
def read(self) -> Union[Text, bytes]: ...
def load(fp: _Reader,
def load(fp: SupportsRead[Union[Text, bytes]],
encoding: Optional[str] = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,

View File

@@ -13,9 +13,12 @@
# is not used, types from this module must be quoted.
import sys
from typing import Protocol, Text, Union, type_check_only
from typing import Protocol, Text, TypeVar, Union
from typing_extensions import Literal
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
# StrPath and AnyPath can be used in places where a
# path can be used instead of a string, starting with Python 3.6.
if sys.version_info >= (3, 6):
@@ -52,9 +55,15 @@ OpenBinaryModeReading = Literal[
]
OpenBinaryMode = Union[OpenBinaryModeUpdating, OpenBinaryModeReading, OpenBinaryModeWriting]
@type_check_only
class HasFileno(Protocol):
def fileno(self) -> int: ...
FileDescriptor = int
FileDescriptorLike = Union[int, HasFileno]
class SupportsRead(Protocol[_T_co]):
def read(self, __length: int = ...) -> _T_co: ...
class SupportsReadline(Protocol[_T_co]):
def readline(self, __length: int = ...) -> _T_co: ...
class SupportsWrite(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> int: ...

View File

@@ -15,7 +15,7 @@ from io import (
TextIOWrapper, FileIO, BufferedRandom, BufferedReader, BufferedWriter
)
from types import TracebackType, CodeType
from _typeshed import AnyPath, OpenBinaryMode, OpenTextMode, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenBinaryModeReading
from _typeshed import AnyPath, OpenBinaryMode, OpenTextMode, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenBinaryModeReading, SupportsWrite
from typing_extensions import Literal
import sys
@@ -1480,17 +1480,13 @@ else:
def ord(__c: Union[Text, bytes]) -> int: ...
if sys.version_info >= (3,):
class _Writer(Protocol):
def write(self, __s: str) -> Any: ...
def print(
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[str]] = ..., flush: bool = ...
) -> None: ...
else:
class _Writer(Protocol):
def write(self, __s: Any) -> Any: ...
# This is only available after from __future__ import print_function.
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ...
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ...) -> None: ...
_E = TypeVar("_E", contravariant=True)
_M = TypeVar("_M", contravariant=True)

View File

@@ -9,7 +9,6 @@ from typing import (
Iterator,
List,
Optional,
Protocol,
Text,
TextIO,
Tuple,
@@ -20,6 +19,7 @@ from typing import (
from types import TracebackType
from socket import socket
from ssl import SSLContext
from _typeshed import SupportsRead, SupportsReadline
_T = TypeVar("_T")
_IntOrStr = Union[int, Text]
@@ -39,12 +39,6 @@ class error_proto(Error): ...
all_errors = Tuple[Type[Exception], ...]
class _Readable(Protocol):
def read(self, __length: int) -> bytes: ...
class _ReadLineable(Protocol):
def readline(self, _length: int) -> bytes: ...
class FTP:
debugging: int
@@ -118,13 +112,13 @@ class FTP:
def storbinary(
self,
cmd: Text,
fp: _Readable,
fp: SupportsRead[bytes],
blocksize: int = ...,
callback: Optional[Callable[[bytes], Any]] = ...,
rest: Optional[_IntOrStr] = ...,
) -> str: ...
def retrlines(self, cmd: Text, callback: Optional[Callable[[str], Any]] = ...) -> str: ...
def storlines(self, cmd: Text, fp: _ReadLineable, callback: Optional[Callable[[bytes], Any]] = ...) -> str: ...
def storlines(self, cmd: Text, fp: SupportsReadline[bytes], callback: Optional[Callable[[bytes], Any]] = ...) -> str: ...
def acct(self, password: Text) -> str: ...
def nlst(self, *args: Text) -> List[str]: ...
# Technically only the last arg can be a Callable but ...

View File

@@ -1,6 +1,7 @@
import sys
from typing import Any, AnyStr, Callable, Container, Dict, IO, List, Mapping, MutableMapping, NoReturn, Optional, Protocol, Text, Tuple, Type, Union
from typing import Any, AnyStr, Callable, Container, Dict, IO, List, Mapping, MutableMapping, NoReturn, Optional, Text, Tuple, Type, Union
from types import FunctionType, MethodType, ModuleType, TracebackType
from _typeshed import SupportsWrite
if sys.version_info >= (3,):
from reprlib import Repr
else:
@@ -133,12 +134,10 @@ text: TextDoc
html: HTMLDoc
class _OldStyleClass: ...
class _Writable(Protocol):
def write(self, __obj: str) -> Any: ...
def resolve(thing: Union[str, object], forceload: bool = ...) -> Optional[Tuple[object, str]]: ...
def render_doc(thing: Union[str, object], title: str = ..., forceload: bool = ..., renderer: Optional[Doc] = ...) -> str: ...
def doc(thing: Union[str, object], title: str = ..., forceload: bool = ..., output: Optional[_Writable] = ...) -> None: ...
def doc(thing: Union[str, object], title: str = ..., forceload: bool = ..., output: Optional[SupportsWrite[str]] = ...) -> None: ...
def writedoc(thing: Union[str, object], forceload: bool = ...) -> None: ...
def writedocs(dir: str, pkgpath: str = ..., done: Optional[Any] = ...) -> None: ...

View File

@@ -1,4 +1,5 @@
from typing import List, Tuple, Optional, Callable, Any, Protocol, Union, Dict, Text
from typing import List, Tuple, Optional, Callable, Any, Union, Dict, Text
from _typeshed import SupportsRead
import pyexpat.errors as errors
import pyexpat.model as model
@@ -15,9 +16,6 @@ class ExpatError(Exception):
error = ExpatError
class _Reader(Protocol):
def read(self, length: int) -> bytes: ...
XML_PARAM_ENTITY_PARSING_NEVER: int
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int
XML_PARAM_ENTITY_PARSING_ALWAYS: int
@@ -26,7 +24,7 @@ _Model = Tuple[int, int, Optional[str], tuple]
class XMLParserType(object):
def Parse(self, __data: Union[Text, bytes], __isfinal: bool = ...) -> int: ...
def ParseFile(self, __file: _Reader) -> int: ...
def ParseFile(self, __file: SupportsRead[bytes]) -> int: ...
def SetBase(self, __base: Text) -> None: ...
def GetBase(self) -> Optional[str]: ...
def GetInputContext(self) -> Optional[bytes]: ...

View File

@@ -3,9 +3,9 @@ import sys
from typing import (
List, Iterable, Callable, Any, Tuple, Sequence, NamedTuple,
AnyStr, Optional, Union, Set, TypeVar, overload, Type, Protocol, Text
AnyStr, Optional, Union, Set, TypeVar, overload, Type, Text
)
from _typeshed import StrPath
from _typeshed import StrPath, SupportsRead, SupportsWrite
if sys.version_info >= (3, 6):
_AnyStr = str
@@ -34,16 +34,7 @@ else:
class SpecialFileError(EnvironmentError): ...
class ExecError(EnvironmentError): ...
_S_co = TypeVar("_S_co", covariant=True)
_S_contra = TypeVar("_S_contra", contravariant=True)
class _Reader(Protocol[_S_co]):
def read(self, length: int) -> _S_co: ...
class _Writer(Protocol[_S_contra]):
def write(self, data: _S_contra) -> Any: ...
def copyfileobj(fsrc: _Reader[AnyStr], fdst: _Writer[AnyStr],
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr],
length: int = ...) -> None: ...
if sys.version_info >= (3,):

View File

@@ -1,8 +1,7 @@
# Stubs for traceback
from typing import Any, Dict, Generator, IO, Iterator, List, Mapping, Optional, Protocol, Tuple, Type, Iterable
from typing import Any, Dict, Generator, IO, Iterator, List, Mapping, Optional, Tuple, Type, Iterable
from types import FrameType, TracebackType
import sys
from _typeshed import SupportsWrite
_PT = Tuple[str, int, str, Optional[str]]
@@ -36,10 +35,8 @@ if sys.version_info >= (3, 5):
def extract_stack(f: Optional[FrameType] = ...,
limit: Optional[int] = ...) -> StackSummary: ...
def format_list(extracted_list: List[FrameSummary]) -> List[str]: ...
class _Writer(Protocol):
def write(self, s: str) -> Any: ...
# undocumented
def print_list(extracted_list: List[FrameSummary], file: Optional[_Writer] = ...) -> None: ...
def print_list(extracted_list: List[FrameSummary], file: Optional[SupportsWrite[str]] = ...) -> None: ...
else:
def extract_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[_PT]: ...
def extract_stack(f: Optional[FrameType] = ...,

View File

@@ -11,7 +11,6 @@ from typing import (
List,
MutableSequence,
Optional,
Protocol,
Sequence,
Text,
Tuple,
@@ -19,7 +18,7 @@ from typing import (
Union,
overload,
)
from _typeshed import AnyPath, FileDescriptor
from _typeshed import AnyPath, FileDescriptor, SupportsWrite
import sys
from typing_extensions import Literal
@@ -60,9 +59,6 @@ else:
_file_or_filename = Union[AnyPath, FileDescriptor, IO[Any]]
if sys.version_info >= (3, 8):
class _Writeable(Protocol):
def write(self, __s: str) -> Any: ...
@overload
def canonicalize(
xml_data: Optional[_parser_input_type] = ...,
@@ -81,7 +77,7 @@ if sys.version_info >= (3, 8):
def canonicalize(
xml_data: Optional[_parser_input_type] = ...,
*,
out: _Writeable,
out: SupportsWrite[str],
from_file: Optional[_file_or_filename] = ...,
with_comments: bool = ...,
strip_text: bool = ...,

View File

@@ -1,23 +1,21 @@
import sys
from typing import Mapping, Text, Optional, Protocol, Union, TextIO
from typing import Mapping, Text, Optional, Union, TextIO
from io import TextIOBase, RawIOBase
from codecs import StreamWriter, StreamReaderWriter
from _typeshed import SupportsWrite
from xml.sax import handler
from xml.sax import xmlreader
class _Writable(Protocol):
def write(self, data: str) -> None: ...
def escape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
class XMLGenerator(handler.ContentHandler):
if sys.version_info >= (3, 0):
def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: str = ..., short_empty_elements: bool = ...) -> None: ...
def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., encoding: str = ..., short_empty_elements: bool = ...) -> None: ...
else:
def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: Text = ...) -> None: ...
def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ..., encoding: Text = ...) -> None: ...
def startDocument(self): ...
def endDocument(self): ...
def startPrefixMapping(self, prefix, uri): ...

View File

@@ -1,5 +1,6 @@
import sys
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Protocol, Type
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Type
from _typeshed import SupportsRead
from .decoder import JSONDecoder as JSONDecoder
from .encoder import JSONEncoder as JSONEncoder
@@ -33,7 +34,7 @@ def dump(obj: Any,
**kwds: Any) -> None: ...
if sys.version_info >= (3, 6):
_LoadsString = Union[str, bytes, bytearray]
_LoadsString = Union[str, bytes]
else:
_LoadsString = str
def loads(s: _LoadsString,
@@ -46,10 +47,7 @@ def loads(s: _LoadsString,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
class _Reader(Protocol):
def read(self) -> _LoadsString: ...
def load(fp: _Reader,
def load(fp: SupportsRead[_LoadsString],
*,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,

View File

@@ -4,19 +4,15 @@ import time
import gzip
import http.client
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Text, Tuple, Type, TypeVar, Union, overload
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Text, Tuple, Type, Union, overload
from typing_extensions import Literal
from types import TracebackType
from datetime import datetime
from _typeshed import SupportsRead, SupportsWrite
_T = TypeVar("_T")
class _HasTimeTuple(Protocol):
class _SupportsTimeTuple(Protocol):
def timetuple(self) -> time.struct_time: ...
class _HasWrite(Protocol):
def write(self, __o: str) -> None: ...
class _HasRead(Protocol):
def read(self) -> bytes: ...
_DateTimeComparable = Union[DateTime, datetime, str, _HasTimeTuple]
_DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple]
_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime, DateTime, Binary]
_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time]
_HostType = Union[Tuple[str, Dict[str, str]], str]
@@ -77,7 +73,7 @@ class DateTime:
def make_comparable(self, other: _DateTimeComparable) -> Tuple[str, str]: ... # undocumented
def timetuple(self) -> time.struct_time: ... # undocumented
def decode(self, data: Any) -> None: ...
def encode(self, out: _HasWrite) -> None: ...
def encode(self, out: SupportsWrite[str]) -> None: ...
def _datetime(data: Any) -> DateTime: ... # undocumented
def _datetime_type(data: str) -> datetime: ... # undocumented
@@ -88,7 +84,7 @@ class Binary:
def __init__(self, data: Optional[bytes] = ...) -> None: ...
def decode(self, data: bytes) -> None: ...
def encode(self, out: _HasWrite) -> None: ...
def encode(self, out: SupportsWrite[str]) -> None: ...
def _binary(data: bytes) -> Binary: ... # undocumented
@@ -204,7 +200,7 @@ class GzipDecodedResponse(gzip.GzipFile): # undocumented
io: io.BytesIO
def __init__(self, response: _HasRead) -> None: ...
def __init__(self, response: SupportsRead[bytes]) -> None: ...
def close(self) -> None: ...
class _Method: # undocumented

View File

@@ -1,7 +1,8 @@
from typing import Any, IO, List, Mapping, MutableMapping, Optional, Protocol, Text, Type, Union
from typing import Any, IO, List, Mapping, MutableMapping, Optional, Text, Type, Union
from _typeshed import StrPath
import datetime
import sys
from _typeshed import SupportsWrite
if sys.version_info >= (3, 6):
_PathLike = StrPath
@@ -11,13 +12,10 @@ elif sys.version_info >= (3, 4):
else:
_PathLike = StrPath
class _Writable(Protocol):
def write(self, obj: str) -> Any: ...
class TomlDecodeError(Exception): ...
def load(f: Union[_PathLike, List[Text], IO[str]], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ...
def loads(s: Text, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ...
def dump(o: Mapping[str, Any], f: _Writable) -> str: ...
def dump(o: Mapping[str, Any], f: SupportsWrite[str]) -> str: ...
def dumps(o: Mapping[str, Any]) -> str: ...

View File

@@ -1,14 +1,9 @@
from typing import Any, AnyStr, Generic, Optional, Protocol, Tuple, TypeVar
from typing import AnyStr, Generic, Tuple
from _typeshed import SupportsWrite
from ..middleware.profiler import *
_T = TypeVar("_T")
_T_contra = TypeVar("_T_contra", contravariant=True)
class _Writable(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> Any: ...
class MergeStream(Generic[_T]):
streams: Tuple[_Writable[_T], ...]
def __init__(self, *streams: _Writable[_T]) -> None: ...
def write(self, data: _T) -> None: ...
class MergeStream(Generic[AnyStr]):
streams: Tuple[SupportsWrite[AnyStr], ...]
def __init__(self, *streams: SupportsWrite[AnyStr]) -> None: ...
def write(self, data: AnyStr) -> None: ...

View File

@@ -13,7 +13,6 @@ from typing import (
MutableSet,
NoReturn,
Optional,
Protocol,
Text,
Tuple,
Type,
@@ -21,6 +20,7 @@ from typing import (
Union,
overload,
)
from _typeshed import SupportsWrite
_K = TypeVar("_K")
_V = TypeVar("_V")
@@ -428,9 +428,6 @@ class WWWAuthenticate(UpdateDictMixin, Dict[str, Any]):
qop: Any
stale: Any
class _Writer(Protocol):
def write(self, data: bytes) -> Any: ...
class FileStorage(object):
name: Optional[Text]
stream: IO[bytes]
@@ -453,7 +450,7 @@ class FileStorage(object):
def mimetype(self) -> str: ...
@property
def mimetype_params(self) -> Dict[str, str]: ...
def save(self, dst: Union[Text, _Writer], buffer_size: int = ...): ...
def save(self, dst: Union[Text, SupportsWrite[bytes]], buffer_size: int = ...): ...
def close(self) -> None: ...
def __nonzero__(self) -> bool: ...
def __bool__(self) -> bool: ...

View File

@@ -2,7 +2,7 @@ import sys
from datetime import datetime, timedelta
from typing import (
Dict, Text, Union, Tuple, Any, Optional, Mapping, Iterable, Callable, List, Type,
TypeVar, Protocol, overload, SupportsInt,
TypeVar, overload, SupportsInt,
)
from _typeshed.wsgi import WSGIEnvironment

View File

@@ -1,5 +1,6 @@
import sys
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Protocol, Tuple
from _typeshed import SupportsWrite
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from ..datastructures import Headers
@@ -9,36 +10,33 @@ class HTTPWarning(Warning): ...
def check_string(context: str, obj: object, stacklevel: int = ...) -> None: ...
class _Readable(Protocol):
class _SupportsReadEtc(Protocol):
def read(self, __size: int = ...) -> bytes: ...
def readline(self, __size: int = ...) -> bytes: ...
def __iter__(self) -> Iterator[bytes]: ...
def close(self) -> Any: ...
class InputStream(object):
def __init__(self, stream: _Readable) -> None: ...
def __init__(self, stream: _SupportsReadEtc) -> None: ...
def read(self, __size: int = ...) -> bytes: ...
def readline(self, __size: int = ...) -> bytes: ...
def __iter__(self) -> Iterator[bytes]: ...
def close(self) -> None: ...
class _FullyWritable(Protocol):
class _SupportsWriteEtc(Protocol):
def write(self, __s: str) -> Any: ...
def flush(self) -> Any: ...
def close(self) -> Any: ...
class ErrorStream(object):
def __init__(self, stream: _FullyWritable) -> None: ...
def __init__(self, stream: _SupportsWriteEtc) -> None: ...
def write(self, s: str) -> None: ...
def flush(self) -> None: ...
def writelines(self, seq: Iterable[str]) -> None: ...
def close(self) -> None: ...
class _Writable(Protocol):
def write(self, __s: str) -> Any: ...
class GuardedWrite(object):
def __init__(self, write: _Writable, chunks: List[int]) -> None: ...
def __init__(self, write: SupportsWrite[str], chunks: List[int]) -> None: ...
def __call__(self, s: str) -> None: ...
class GuardedIterator(object):

View File

@@ -1,4 +1,5 @@
from typing import Any, Optional, Protocol, Iterable, Text
from typing import Any, Optional, Iterable, Text
from _typeshed import SupportsRead
from _typeshed.wsgi import WSGIEnvironment, InputStream
from .middleware.dispatcher import DispatcherMiddleware as DispatcherMiddleware
@@ -26,15 +27,12 @@ class ClosingIterator:
def __next__(self): ...
def close(self): ...
class _Readable(Protocol):
def read(self, size: int = ...) -> bytes: ...
def wrap_file(environ: WSGIEnvironment, file: _Readable, buffer_size: int = ...) -> Iterable[bytes]: ...
def wrap_file(environ: WSGIEnvironment, file: SupportsRead[bytes], buffer_size: int = ...) -> Iterable[bytes]: ...
class FileWrapper:
file: _Readable
file: SupportsRead[bytes]
buffer_size: int
def __init__(self, file: _Readable, buffer_size: int = ...) -> None: ...
def __init__(self, file: SupportsRead[bytes], buffer_size: int = ...) -> None: ...
def close(self) -> None: ...
def seekable(self) -> bool: ...
def seek(self, offset: int, whence: int = ...) -> None: ...

View File

@@ -1,13 +1,12 @@
from typing import Any, IO, Mapping, Optional, Sequence, Text, Union
from typing_extensions import Protocol
from _typeshed import SupportsRead
from yaml.constructor import BaseConstructor, Constructor, SafeConstructor
from yaml.representer import BaseRepresenter, Representer, SafeRepresenter
from yaml.resolver import BaseResolver, Resolver
from yaml.serializer import Serializer
class _Readable(Protocol):
def read(self, size: int) -> Union[Text, bytes]: ...
_Readable = SupportsRead[Union[Text, bytes]]
class CParser:
def __init__(self, stream: Union[str, bytes, _Readable]) -> None: ...