Relax type of xml.etree.ElementTree.XMLParser target argument (#4538)

The target argument can be an arbitrary object.
If it has certain methods, they are used by XMLParser,
missing methods are ignored.

Ideally, we'd be able to type the potentially missing
methods correctly, but currently the type system is
unable to do so.

Fixes #4537
This commit is contained in:
Yuri Khan
2020-09-14 17:50:12 +07:00
committed by GitHub
parent dc0b4262c3
commit 87b758b0da

View File

@@ -363,14 +363,14 @@ if sys.version_info >= (3, 8):
class XMLParser:
parser: Any
target: TreeBuilder
target: Any
# TODO-what is entity used for???
entity: Any
version: str
if sys.version_info >= (3, 8):
def __init__(self, *, target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ...
def __init__(self, *, target: Any = ..., encoding: Optional[str] = ...) -> None: ...
else:
def __init__(self, html: int = ..., target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ...
def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ...
def doctype(self, __name: str, __pubid: str, __system: str) -> None: ...
def close(self) -> Element: ...
def close(self) -> Any: ...
def feed(self, __data: _parser_input_type) -> None: ...