mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-23 12:21:27 +08:00
Akuli and srittau: Remove Python 2 branches from Python 3 stubs (#5461)
* run script and do some manual changes (Akuli) * do the whole thing manually (srittau) * merge changes (Akuli) Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
@@ -47,14 +47,7 @@ _parser_input_type = Union[bytes, Text]
|
||||
_str_argument_type = Union[str, Text]
|
||||
|
||||
# Type for return values from individual tag/attr/text values
|
||||
if sys.version_info >= (3,):
|
||||
# note: in python3, everything comes out as str, yay:
|
||||
_str_result_type = str
|
||||
else:
|
||||
# in python2, if the tag/attribute/text wasn't decode-able as ascii, it
|
||||
# comes out as a unicode string; otherwise it comes out as str. (see
|
||||
# _fixtext function in the source). Client code knows best:
|
||||
_str_result_type = Any
|
||||
_str_result_type = str
|
||||
|
||||
_file_or_filename = Union[AnyPath, FileDescriptor, IO[Any]]
|
||||
|
||||
@@ -123,10 +116,7 @@ class Element(MutableSequence[Element]):
|
||||
def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ...
|
||||
@overload
|
||||
def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ...
|
||||
if sys.version_info >= (3, 2):
|
||||
def insert(self, __index: int, __subelement: Element) -> None: ...
|
||||
else:
|
||||
def insert(self, __index: int, __element: Element) -> None: ...
|
||||
def insert(self, __index: int, __subelement: Element) -> None: ...
|
||||
def items(self) -> ItemsView[_str_result_type, _str_result_type]: ...
|
||||
def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ...
|
||||
def iterfind(
|
||||
@@ -193,26 +183,16 @@ class ElementTree:
|
||||
def iterfind(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> Generator[Element, None, None]: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def write(
|
||||
self,
|
||||
file_or_filename: _file_or_filename,
|
||||
encoding: Optional[str] = ...,
|
||||
xml_declaration: Optional[bool] = ...,
|
||||
default_namespace: Optional[_str_argument_type] = ...,
|
||||
method: Optional[str] = ...,
|
||||
*,
|
||||
short_empty_elements: bool = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def write(
|
||||
self,
|
||||
file_or_filename: _file_or_filename,
|
||||
encoding: Optional[str] = ...,
|
||||
xml_declaration: Optional[bool] = ...,
|
||||
default_namespace: Optional[_str_argument_type] = ...,
|
||||
method: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
def write(
|
||||
self,
|
||||
file_or_filename: _file_or_filename,
|
||||
encoding: Optional[str] = ...,
|
||||
xml_declaration: Optional[bool] = ...,
|
||||
default_namespace: Optional[_str_argument_type] = ...,
|
||||
method: Optional[str] = ...,
|
||||
*,
|
||||
short_empty_elements: bool = ...,
|
||||
) -> None: ...
|
||||
def write_c14n(self, file: _file_or_filename) -> None: ...
|
||||
|
||||
def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ...
|
||||
@@ -279,7 +259,7 @@ if sys.version_info >= (3, 8):
|
||||
short_empty_elements: bool = ...,
|
||||
) -> List[Any]: ...
|
||||
|
||||
elif sys.version_info >= (3,):
|
||||
else:
|
||||
@overload
|
||||
def tostring(
|
||||
element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ...
|
||||
@@ -303,10 +283,6 @@ elif sys.version_info >= (3,):
|
||||
element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ...
|
||||
) -> List[Any]: ...
|
||||
|
||||
else:
|
||||
def tostring(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ...
|
||||
def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ...
|
||||
|
||||
def dump(elem: Element) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 9):
|
||||
@@ -317,12 +293,11 @@ def iterparse(
|
||||
source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ...
|
||||
) -> Iterator[Tuple[str, Any]]: ...
|
||||
|
||||
if sys.version_info >= (3, 4):
|
||||
class XMLPullParser:
|
||||
def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ...
|
||||
def feed(self, data: bytes) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def read_events(self) -> Iterator[Tuple[str, Element]]: ...
|
||||
class XMLPullParser:
|
||||
def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ...
|
||||
def feed(self, data: bytes) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def read_events(self) -> Iterator[Tuple[str, Element]]: ...
|
||||
|
||||
def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ...
|
||||
def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ...
|
||||
|
||||
Reference in New Issue
Block a user