mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-20 10:02:51 +08:00
Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory() * Add memfd_create() and flags * Add type annotation to flags * Add stat_result.st_reparse_tag and flags * Add ncurses_version * Add Path.link_to() * Add Picker.reducer_override() * Add plistlib.UID * Add has_dualstack_ipv6() and create_server() * Add shlex.join() * Add SSL methods and fields * Add Python 3.8 statistics functions and classes * Remove obsolete sys.subversion * Add sys.unraisablehook * Add threading.excepthook * Add get_native_id() and Thread.native_id * Add Python 3.8 tkinter methods * Add CLOCK_UPTIME_RAW * Add SupportsIndex * Add typing.get_origin() and get_args() * Add unicodedata.is_normalized * Add unittest.mock.AsyncMock Currently this is just an alias for Any like Mock and MagicMock. All of these classes should probably be sub-classing Any and add their own methods. See also #3224. * Add unittest cleanup methods * Add IsolatedAsyncioTestCase * Add ElementTree.canonicalize() and C14NWriterTarget * cProfile.Profile can be used as a context manager * Add asyncio task name handling * mmap.flush() now always returns None * Add posonlyargcount to CodeType
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
# Stubs for xml.etree.ElementTree
|
||||
|
||||
from typing import Any, Callable, Dict, Generator, IO, ItemsView, Iterable, Iterator, KeysView, List, MutableSequence, Optional, overload, Sequence, Text, Tuple, TypeVar, Union
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
IO,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
Iterator,
|
||||
KeysView,
|
||||
List,
|
||||
MutableSequence,
|
||||
Optional,
|
||||
Protocol,
|
||||
Sequence,
|
||||
Text,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
import io
|
||||
import sys
|
||||
|
||||
@@ -43,6 +63,41 @@ else:
|
||||
# _fixtext function in the source). Client code knows best:
|
||||
_str_result_type = Any
|
||||
|
||||
_file_or_filename = Union[str, bytes, int, 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] = ...,
|
||||
*,
|
||||
out: None = ...,
|
||||
from_file: Optional[_file_or_filename] = ...,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
rewrite_prefixes: bool = ...,
|
||||
qname_aware_tags: Optional[Iterable[str]] = ...,
|
||||
qname_aware_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: Optional[_parser_input_type] = ...,
|
||||
*,
|
||||
out: _Writeable,
|
||||
from_file: Optional[_file_or_filename] = ...,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
rewrite_prefixes: bool = ...,
|
||||
qname_aware_tags: Optional[Iterable[str]] = ...,
|
||||
qname_aware_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class Element(MutableSequence[Element]):
|
||||
tag: _str_result_type
|
||||
attrib: Dict[_str_result_type, _str_result_type]
|
||||
@@ -100,9 +155,6 @@ class QName:
|
||||
text: str
|
||||
def __init__(self, text_or_uri: _str_argument_type, tag: Optional[_str_argument_type] = ...) -> None: ...
|
||||
|
||||
|
||||
_file_or_filename = Union[str, bytes, int, IO[Any]]
|
||||
|
||||
class ElementTree:
|
||||
def __init__(self, element: Optional[Element] = ..., file: Optional[_file_or_filename] = ...) -> None: ...
|
||||
def getroot(self) -> Element: ...
|
||||
@@ -176,6 +228,22 @@ class TreeBuilder:
|
||||
def start(self, tag: _parser_input_type, attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ...
|
||||
def end(self, tag: _parser_input_type) -> Element: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class C14NWriterTarget:
|
||||
def __init__(
|
||||
self,
|
||||
write: Callable[[str], Any],
|
||||
*,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
rewrite_prefixes: bool = ...,
|
||||
qname_aware_tags: Optional[Iterable[str]] = ...,
|
||||
qname_aware_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class XMLParser:
|
||||
parser: Any
|
||||
target: TreeBuilder
|
||||
|
||||
Reference in New Issue
Block a user