mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-29 23:26:54 +08:00
Remove Python 3.7 branches (#11238)
This commit is contained in:
@@ -6,10 +6,12 @@ from typing import Any, TypeVar, overload
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard
|
||||
|
||||
__all__ = [
|
||||
"C14NWriterTarget",
|
||||
"Comment",
|
||||
"dump",
|
||||
"Element",
|
||||
"ElementTree",
|
||||
"canonicalize",
|
||||
"fromstring",
|
||||
"fromstringlist",
|
||||
"iselement",
|
||||
@@ -31,9 +33,6 @@ __all__ = [
|
||||
"register_namespace",
|
||||
]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ += ["C14NWriterTarget", "canonicalize"]
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ += ["indent"]
|
||||
|
||||
@@ -50,36 +49,34 @@ class ParseError(SyntaxError):
|
||||
|
||||
# In reality it works based on `.tag` attribute duck typing.
|
||||
def iselement(element: object) -> TypeGuard[Element]: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: str | ReadableBuffer | None = None,
|
||||
*,
|
||||
out: None = None,
|
||||
from_file: _FileRead | None = None,
|
||||
with_comments: bool = False,
|
||||
strip_text: bool = False,
|
||||
rewrite_prefixes: bool = False,
|
||||
qname_aware_tags: Iterable[str] | None = None,
|
||||
qname_aware_attrs: Iterable[str] | None = None,
|
||||
exclude_attrs: Iterable[str] | None = None,
|
||||
exclude_tags: Iterable[str] | None = None,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: str | ReadableBuffer | None = None,
|
||||
*,
|
||||
out: SupportsWrite[str],
|
||||
from_file: _FileRead | None = None,
|
||||
with_comments: bool = False,
|
||||
strip_text: bool = False,
|
||||
rewrite_prefixes: bool = False,
|
||||
qname_aware_tags: Iterable[str] | None = None,
|
||||
qname_aware_attrs: Iterable[str] | None = None,
|
||||
exclude_attrs: Iterable[str] | None = None,
|
||||
exclude_tags: Iterable[str] | None = None,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: str | ReadableBuffer | None = None,
|
||||
*,
|
||||
out: None = None,
|
||||
from_file: _FileRead | None = None,
|
||||
with_comments: bool = False,
|
||||
strip_text: bool = False,
|
||||
rewrite_prefixes: bool = False,
|
||||
qname_aware_tags: Iterable[str] | None = None,
|
||||
qname_aware_attrs: Iterable[str] | None = None,
|
||||
exclude_attrs: Iterable[str] | None = None,
|
||||
exclude_tags: Iterable[str] | None = None,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: str | ReadableBuffer | None = None,
|
||||
*,
|
||||
out: SupportsWrite[str],
|
||||
from_file: _FileRead | None = None,
|
||||
with_comments: bool = False,
|
||||
strip_text: bool = False,
|
||||
rewrite_prefixes: bool = False,
|
||||
qname_aware_tags: Iterable[str] | None = None,
|
||||
qname_aware_attrs: Iterable[str] | None = None,
|
||||
exclude_attrs: Iterable[str] | None = None,
|
||||
exclude_tags: Iterable[str] | None = None,
|
||||
) -> None: ...
|
||||
|
||||
class Element:
|
||||
tag: str
|
||||
@@ -172,93 +169,66 @@ class ElementTree:
|
||||
def write_c14n(self, file: _FileWriteC14N) -> None: ...
|
||||
|
||||
def register_namespace(prefix: str, uri: str) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element,
|
||||
encoding: None = None,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> bytes: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element,
|
||||
encoding: Literal["unicode"],
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element,
|
||||
encoding: str,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> Any: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
encoding: None = None,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> list[bytes]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
encoding: Literal["unicode"],
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> list[str]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
encoding: str,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> list[Any]: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element, encoding: None = None, method: str | None = None, *, short_empty_elements: bool = True
|
||||
) -> bytes: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element, encoding: Literal["unicode"], method: str | None = None, *, short_empty_elements: bool = True
|
||||
) -> str: ...
|
||||
@overload
|
||||
def tostring(element: Element, encoding: str, method: str | None = None, *, short_empty_elements: bool = True) -> Any: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element, encoding: None = None, method: str | None = None, *, short_empty_elements: bool = True
|
||||
) -> list[bytes]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element, encoding: Literal["unicode"], method: str | None = None, *, short_empty_elements: bool = True
|
||||
) -> list[str]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element, encoding: str, method: str | None = None, *, short_empty_elements: bool = True
|
||||
) -> list[Any]: ...
|
||||
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element,
|
||||
encoding: None = None,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> bytes: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element,
|
||||
encoding: Literal["unicode"],
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element,
|
||||
encoding: str,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> Any: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
encoding: None = None,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> list[bytes]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
encoding: Literal["unicode"],
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> list[str]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
encoding: str,
|
||||
method: str | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
) -> list[Any]: ...
|
||||
def dump(elem: Element) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@@ -297,21 +267,18 @@ def fromstringlist(sequence: Sequence[str | ReadableBuffer], parser: XMLParser |
|
||||
_ElementFactory: TypeAlias = Callable[[Any, dict[Any, Any]], Element]
|
||||
|
||||
class TreeBuilder:
|
||||
if sys.version_info >= (3, 8):
|
||||
# comment_factory can take None because passing None to Comment is not an error
|
||||
def __init__(
|
||||
self,
|
||||
element_factory: _ElementFactory | None = ...,
|
||||
*,
|
||||
comment_factory: Callable[[str | None], Element] | None = ...,
|
||||
pi_factory: Callable[[str, str | None], Element] | None = ...,
|
||||
insert_comments: bool = ...,
|
||||
insert_pis: bool = ...,
|
||||
) -> None: ...
|
||||
insert_comments: bool
|
||||
insert_pis: bool
|
||||
else:
|
||||
def __init__(self, element_factory: _ElementFactory | None = ...) -> None: ...
|
||||
# comment_factory can take None because passing None to Comment is not an error
|
||||
def __init__(
|
||||
self,
|
||||
element_factory: _ElementFactory | None = ...,
|
||||
*,
|
||||
comment_factory: Callable[[str | None], Element] | None = ...,
|
||||
pi_factory: Callable[[str, str | None], Element] | None = ...,
|
||||
insert_comments: bool = ...,
|
||||
insert_pis: bool = ...,
|
||||
) -> None: ...
|
||||
insert_comments: bool
|
||||
insert_pis: bool
|
||||
|
||||
def close(self) -> Element: ...
|
||||
def data(self, __data: str) -> None: ...
|
||||
@@ -319,31 +286,29 @@ class TreeBuilder:
|
||||
# depending on what the particular factory supports.
|
||||
def start(self, __tag: Any, __attrs: dict[Any, Any]) -> Element: ...
|
||||
def end(self, __tag: str) -> Element: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
# These two methods have pos-only parameters in the C implementation
|
||||
def comment(self, __text: str | None) -> Element: ...
|
||||
def pi(self, __target: str, __text: str | None = None) -> Element: ...
|
||||
# These two methods have pos-only parameters in the C implementation
|
||||
def comment(self, __text: str | None) -> Element: ...
|
||||
def pi(self, __target: str, __text: str | None = None) -> Element: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class C14NWriterTarget:
|
||||
def __init__(
|
||||
self,
|
||||
write: Callable[[str], object],
|
||||
*,
|
||||
with_comments: bool = False,
|
||||
strip_text: bool = False,
|
||||
rewrite_prefixes: bool = False,
|
||||
qname_aware_tags: Iterable[str] | None = None,
|
||||
qname_aware_attrs: Iterable[str] | None = None,
|
||||
exclude_attrs: Iterable[str] | None = None,
|
||||
exclude_tags: Iterable[str] | None = None,
|
||||
) -> None: ...
|
||||
def data(self, data: str) -> None: ...
|
||||
def start_ns(self, prefix: str, uri: str) -> None: ...
|
||||
def start(self, tag: str, attrs: Mapping[str, str]) -> None: ...
|
||||
def end(self, tag: str) -> None: ...
|
||||
def comment(self, text: str) -> None: ...
|
||||
def pi(self, target: str, data: str) -> None: ...
|
||||
class C14NWriterTarget:
|
||||
def __init__(
|
||||
self,
|
||||
write: Callable[[str], object],
|
||||
*,
|
||||
with_comments: bool = False,
|
||||
strip_text: bool = False,
|
||||
rewrite_prefixes: bool = False,
|
||||
qname_aware_tags: Iterable[str] | None = None,
|
||||
qname_aware_attrs: Iterable[str] | None = None,
|
||||
exclude_attrs: Iterable[str] | None = None,
|
||||
exclude_tags: Iterable[str] | None = None,
|
||||
) -> None: ...
|
||||
def data(self, data: str) -> None: ...
|
||||
def start_ns(self, prefix: str, uri: str) -> None: ...
|
||||
def start(self, tag: str, attrs: Mapping[str, str]) -> None: ...
|
||||
def end(self, tag: str) -> None: ...
|
||||
def comment(self, text: str) -> None: ...
|
||||
def pi(self, target: str, data: str) -> None: ...
|
||||
|
||||
class XMLParser:
|
||||
parser: Any
|
||||
@@ -351,11 +316,6 @@ class XMLParser:
|
||||
# TODO-what is entity used for???
|
||||
entity: Any
|
||||
version: str
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(self, *, target: Any = ..., encoding: str | None = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, html: int = ..., target: Any = ..., encoding: str | None = ...) -> None: ...
|
||||
def doctype(self, __name: str, __pubid: str, __system: str) -> None: ...
|
||||
|
||||
def __init__(self, *, target: Any = ..., encoding: str | None = ...) -> None: ...
|
||||
def close(self) -> Any: ...
|
||||
def feed(self, __data: str | ReadableBuffer) -> None: ...
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import sys
|
||||
from _typeshed import ReadableBuffer, StrPath, SupportsRead, _T_co
|
||||
from collections.abc import Iterable
|
||||
from typing import Protocol
|
||||
@@ -16,21 +15,11 @@ from xml.sax.xmlreader import XMLReader
|
||||
class _SupportsReadClose(SupportsRead[_T_co], Protocol[_T_co]):
|
||||
def close(self) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
_Source: TypeAlias = StrPath | _SupportsReadClose[bytes] | _SupportsReadClose[str]
|
||||
else:
|
||||
_Source: TypeAlias = str | _SupportsReadClose[bytes] | _SupportsReadClose[str]
|
||||
_Source: TypeAlias = StrPath | _SupportsReadClose[bytes] | _SupportsReadClose[str]
|
||||
|
||||
default_parser_list: list[str]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
def make_parser(parser_list: Iterable[str] = ()) -> XMLReader: ...
|
||||
|
||||
else:
|
||||
|
||||
def make_parser(parser_list: list[str] = []) -> XMLReader: ...
|
||||
|
||||
def make_parser(parser_list: Iterable[str] = ()) -> XMLReader: ...
|
||||
def parse(source: _Source, handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ...
|
||||
def parseString(string: ReadableBuffer | str, handler: ContentHandler, errorHandler: ErrorHandler | None = ...) -> None: ...
|
||||
def _create_parser(parser_name: str) -> XMLReader: ...
|
||||
|
||||
Reference in New Issue
Block a user