From 6812ea50e8202fd4d3175a70fdaf424da3708eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20M=C2=AA=20Fern=C3=A1ndez?= Date: Wed, 24 Apr 2024 17:57:20 +0200 Subject: [PATCH] Applied `black` over copied defusedxml stubs --- mypy-stubs/defusedxml/ElementTree.pyi | 72 ++++++++++++++++++++++---- mypy-stubs/defusedxml/__init__.pyi | 8 ++- mypy-stubs/defusedxml/cElementTree.pyi | 12 ++++- mypy-stubs/defusedxml/common.pyi | 22 ++++++-- mypy-stubs/defusedxml/expatbuilder.pyi | 33 +++++++++--- mypy-stubs/defusedxml/lxml.pyi | 10 +++- mypy-stubs/defusedxml/xmlrpc.pyi | 24 +++++++-- 7 files changed, 153 insertions(+), 28 deletions(-) diff --git a/mypy-stubs/defusedxml/ElementTree.pyi b/mypy-stubs/defusedxml/ElementTree.pyi index 999744f7..07479c15 100644 --- a/mypy-stubs/defusedxml/ElementTree.pyi +++ b/mypy-stubs/defusedxml/ElementTree.pyi @@ -1,7 +1,14 @@ from collections.abc import Iterator, Sequence from typing import Any from _typeshed import SupportsRead -from xml.etree.ElementTree import Element, ElementTree, ParseError as ParseError, TreeBuilder as _TreeBuilder, XMLParser as _XMLParser, tostring as tostring +from xml.etree.ElementTree import ( + Element, + ElementTree, + ParseError as ParseError, + TreeBuilder as _TreeBuilder, + XMLParser as _XMLParser, + tostring as tostring, +) class DefusedXMLParser(_XMLParser): forbid_dtd: bool @@ -9,17 +16,45 @@ class DefusedXMLParser(_XMLParser): forbid_external: bool def __init__( self, - html: object | bool =..., + html: object | bool = ..., target: _TreeBuilder | None = None, encoding: str | None = None, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True, ) -> None: ... - def defused_start_doctype_decl(self, name: str | None, sysid: str | None, pubid: str | None, has_internal_subset: bool) -> None: ... - def defused_entity_decl(self, name: str | None, is_parameter_entity: bool, value: str | None, base: str | None, sysid: str | None, pubid: str | None, notation_name: str | None) -> None: ... - def defused_unparsed_entity_decl(self, name: str | None, base: str | None, sysid: str | None, pubid: str | None, notation_name: str | None) -> None: ... - def defused_external_entity_ref_handler(self, context: str | None, base: str | None, sysid: str | None, pubid: str | None) -> None: ... + def defused_start_doctype_decl( + self, + name: str | None, + sysid: str | None, + pubid: str | None, + has_internal_subset: bool, + ) -> None: ... + def defused_entity_decl( + self, + name: str | None, + is_parameter_entity: bool, + value: str | None, + base: str | None, + sysid: str | None, + pubid: str | None, + notation_name: str | None, + ) -> None: ... + def defused_unparsed_entity_decl( + self, + name: str | None, + base: str | None, + sysid: str | None, + pubid: str | None, + notation_name: str | None, + ) -> None: ... + def defused_external_entity_ref_handler( + self, + context: str | None, + base: str | None, + sysid: str | None, + pubid: str | None, + ) -> None: ... XMLTreeBuilder = DefusedXMLParser XMLParse = DefusedXMLParser @@ -27,7 +62,11 @@ XMLParser = DefusedXMLParser # wrapper to xml.etree.ElementTree.parse def parse( - source: str | SupportsRead[bytes] | SupportsRead[str], parser: _XMLParser | None = None, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True + source: str | SupportsRead[bytes] | SupportsRead[str], + parser: _XMLParser | None = None, + forbid_dtd: bool = False, + forbid_entities: bool = True, + forbid_external: bool = True, ) -> ElementTree: ... # wrapper to xml.etree.ElementTree.iterparse @@ -39,8 +78,23 @@ def iterparse( forbid_entities: bool = True, forbid_external: bool = True, ) -> Iterator[tuple[str, Any]]: ... -def fromstring(text: str, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True) -> Element: ... +def fromstring( + text: str, + forbid_dtd: bool = False, + forbid_entities: bool = True, + forbid_external: bool = True, +) -> Element: ... XML = fromstring -__all__ = ["ParseError", "XML", "XMLParse", "XMLParser", "XMLTreeBuilder", "fromstring", "iterparse", "parse", "tostring"] +__all__ = [ + "ParseError", + "XML", + "XMLParse", + "XMLParser", + "XMLTreeBuilder", + "fromstring", + "iterparse", + "parse", + "tostring", +] diff --git a/mypy-stubs/defusedxml/__init__.pyi b/mypy-stubs/defusedxml/__init__.pyi index 39680046..ae5d7e56 100644 --- a/mypy-stubs/defusedxml/__init__.pyi +++ b/mypy-stubs/defusedxml/__init__.pyi @@ -6,4 +6,10 @@ from .common import ( NotSupportedError as NotSupportedError, ) -__all__ = ["DefusedXmlException", "DTDForbidden", "EntitiesForbidden", "ExternalReferenceForbidden", "NotSupportedError"] +__all__ = [ + "DefusedXmlException", + "DTDForbidden", + "EntitiesForbidden", + "ExternalReferenceForbidden", + "NotSupportedError", +] diff --git a/mypy-stubs/defusedxml/cElementTree.pyi b/mypy-stubs/defusedxml/cElementTree.pyi index 8fe92b53..626e63ce 100644 --- a/mypy-stubs/defusedxml/cElementTree.pyi +++ b/mypy-stubs/defusedxml/cElementTree.pyi @@ -10,4 +10,14 @@ from .ElementTree import ( tostring as tostring, ) -__all__ = ["ParseError", "XML", "XMLParse", "XMLParser", "XMLTreeBuilder", "fromstring", "iterparse", "parse", "tostring"] +__all__ = [ + "ParseError", + "XML", + "XMLParse", + "XMLParser", + "XMLTreeBuilder", + "fromstring", + "iterparse", + "parse", + "tostring", +] diff --git a/mypy-stubs/defusedxml/common.pyi b/mypy-stubs/defusedxml/common.pyi index 37b8bd2f..9b45ba17 100644 --- a/mypy-stubs/defusedxml/common.pyi +++ b/mypy-stubs/defusedxml/common.pyi @@ -6,7 +6,9 @@ class DTDForbidden(DefusedXmlException): name: str | None sysid: str | None pubid: str | None - def __init__(self, name: str | None, sysid: str | None, pubid: str | None) -> None: ... + def __init__( + self, name: str | None, sysid: str | None, pubid: str | None + ) -> None: ... class EntitiesForbidden(DefusedXmlException): name: str | None @@ -15,13 +17,27 @@ class EntitiesForbidden(DefusedXmlException): sysid: str | None pubid: str | None notation_name: str | None - def __init__(self, name: str | None, value: str | None, base: str | None, sysid: str | None, pubid: str | None, notation_name: str | None) -> None: ... + def __init__( + self, + name: str | None, + value: str | None, + base: str | None, + sysid: str | None, + pubid: str | None, + notation_name: str | None, + ) -> None: ... class ExternalReferenceForbidden(DefusedXmlException): context: str | None base: str | None sysid: str | None pubid: str | None - def __init__(self, context: str | None, base: str | None, sysid: str | None, pubid: str | None) -> None: ... + def __init__( + self, + context: str | None, + base: str | None, + sysid: str | None, + pubid: str | None, + ) -> None: ... class NotSupportedError(DefusedXmlException): ... diff --git a/mypy-stubs/defusedxml/expatbuilder.pyi b/mypy-stubs/defusedxml/expatbuilder.pyi index 0c6f4b7b..1f53c12a 100644 --- a/mypy-stubs/defusedxml/expatbuilder.pyi +++ b/mypy-stubs/defusedxml/expatbuilder.pyi @@ -1,5 +1,8 @@ from _typeshed import SupportsRead -from xml.dom.expatbuilder import ExpatBuilder as _ExpatBuilder, Namespaces as _Namespaces +from xml.dom.expatbuilder import ( + ExpatBuilder as _ExpatBuilder, + Namespaces as _Namespaces, +) from xml.dom.minidom import Document from xml.dom.xmlbuilder import Options @@ -10,12 +13,24 @@ class DefusedExpatBuilder(_ExpatBuilder): forbid_entities: bool forbid_external: bool def __init__( - self, options: Options | None = None, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True + self, + options: Options | None = None, + forbid_dtd: bool = False, + forbid_entities: bool = True, + forbid_external: bool = True, + ) -> None: ... + def defused_start_doctype_decl( + self, name, sysid, pubid, has_internal_subset + ) -> None: ... + def defused_entity_decl( + self, name, is_parameter_entity, value, base, sysid, pubid, notation_name + ) -> None: ... + def defused_unparsed_entity_decl( + self, name, base, sysid, pubid, notation_name + ) -> None: ... + def defused_external_entity_ref_handler( + self, context, base, sysid, pubid ) -> None: ... - def defused_start_doctype_decl(self, name, sysid, pubid, has_internal_subset) -> None: ... - def defused_entity_decl(self, name, is_parameter_entity, value, base, sysid, pubid, notation_name) -> None: ... - def defused_unparsed_entity_decl(self, name, base, sysid, pubid, notation_name) -> None: ... - def defused_external_entity_ref_handler(self, context, base, sysid, pubid) -> None: ... def install(self, parser) -> None: ... class DefusedExpatBuilderNS(_Namespaces, DefusedExpatBuilder): @@ -30,5 +45,9 @@ def parse( forbid_external: bool = True, ) -> Document: ... def parseString( - string: str, namespaces: bool = True, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True + string: str, + namespaces: bool = True, + forbid_dtd: bool = False, + forbid_entities: bool = True, + forbid_external: bool = True, ) -> Document: ... diff --git a/mypy-stubs/defusedxml/lxml.pyi b/mypy-stubs/defusedxml/lxml.pyi index 10cb30a4..1cab02e8 100644 --- a/mypy-stubs/defusedxml/lxml.pyi +++ b/mypy-stubs/defusedxml/lxml.pyi @@ -30,7 +30,9 @@ class GlobalParserTLS(threading.local): getDefaultParser: Incomplete -def check_docinfo(elementtree, forbid_dtd: bool = ..., forbid_entities: bool = ...) -> None: ... +def check_docinfo( + elementtree, forbid_dtd: bool = ..., forbid_entities: bool = ... +) -> None: ... def parse( source, parser: Incomplete | None = ..., @@ -39,7 +41,11 @@ def parse( forbid_entities: bool = ..., ): ... def fromstring( - text, parser: Incomplete | None = ..., base_url: Incomplete | None = ..., forbid_dtd: bool = ..., forbid_entities: bool = ... + text, + parser: Incomplete | None = ..., + base_url: Incomplete | None = ..., + forbid_dtd: bool = ..., + forbid_entities: bool = ..., ): ... XML = fromstring diff --git a/mypy-stubs/defusedxml/xmlrpc.pyi b/mypy-stubs/defusedxml/xmlrpc.pyi index cddcb3f5..b3501f34 100644 --- a/mypy-stubs/defusedxml/xmlrpc.pyi +++ b/mypy-stubs/defusedxml/xmlrpc.pyi @@ -15,11 +15,25 @@ class DefusedExpatParser(ExpatParser): forbid_dtd: bool forbid_entities: bool forbid_external: bool - def __init__(self, target, forbid_dtd: bool = False, forbid_entities: bool = True, forbid_external: bool = True) -> None: ... - def defused_start_doctype_decl(self, name, sysid, pubid, has_internal_subset) -> None: ... - def defused_entity_decl(self, name, is_parameter_entity, value, base, sysid, pubid, notation_name) -> None: ... - def defused_unparsed_entity_decl(self, name, base, sysid, pubid, notation_name) -> None: ... - def defused_external_entity_ref_handler(self, context, base, sysid, pubid) -> None: ... + def __init__( + self, + target, + forbid_dtd: bool = False, + forbid_entities: bool = True, + forbid_external: bool = True, + ) -> None: ... + def defused_start_doctype_decl( + self, name, sysid, pubid, has_internal_subset + ) -> None: ... + def defused_entity_decl( + self, name, is_parameter_entity, value, base, sysid, pubid, notation_name + ) -> None: ... + def defused_unparsed_entity_decl( + self, name, base, sysid, pubid, notation_name + ) -> None: ... + def defused_external_entity_ref_handler( + self, context, base, sysid, pubid + ) -> None: ... def monkey_patch() -> None: ... def unmonkey_patch() -> None: ...