mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Add IO protocols to _typeshed (#4230)
This commit is contained in:
@@ -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 = ...,
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
Reference in New Issue
Block a user