Skip to content

Commit

Permalink
Applied black over copied defusedxml stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfernandez committed Apr 24, 2024
1 parent 9887a98 commit 6812ea5
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 28 deletions.
72 changes: 63 additions & 9 deletions mypy-stubs/defusedxml/ElementTree.pyi
Original file line number Diff line number Diff line change
@@ -1,33 +1,72 @@
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
forbid_entities: bool
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
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
Expand All @@ -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",
]
8 changes: 7 additions & 1 deletion mypy-stubs/defusedxml/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ from .common import (
NotSupportedError as NotSupportedError,
)

__all__ = ["DefusedXmlException", "DTDForbidden", "EntitiesForbidden", "ExternalReferenceForbidden", "NotSupportedError"]
__all__ = [
"DefusedXmlException",
"DTDForbidden",
"EntitiesForbidden",
"ExternalReferenceForbidden",
"NotSupportedError",
]
12 changes: 11 additions & 1 deletion mypy-stubs/defusedxml/cElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
22 changes: 19 additions & 3 deletions mypy-stubs/defusedxml/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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): ...
33 changes: 26 additions & 7 deletions mypy-stubs/defusedxml/expatbuilder.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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):
Expand All @@ -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: ...
10 changes: 8 additions & 2 deletions mypy-stubs/defusedxml/lxml.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...,
Expand All @@ -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
Expand Down
24 changes: 19 additions & 5 deletions mypy-stubs/defusedxml/xmlrpc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

0 comments on commit 6812ea5

Please sign in to comment.