From ece96777a7e38450c761d1511d8ecb0b9b84ee42 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 29 Nov 2018 16:29:59 +0100 Subject: [PATCH] Re-export pyexpat instead of using check_consistency (#2649) --- stdlib/2and3/xml/parsers/expat/__init__.pyi | 76 +-------------------- stdlib/2and3/xml/parsers/expat/errors.pyi | 45 +----------- stdlib/2and3/xml/parsers/expat/model.pyi | 12 +--- tests/check_consistent.py | 3 - 4 files changed, 3 insertions(+), 133 deletions(-) diff --git a/stdlib/2and3/xml/parsers/expat/__init__.pyi b/stdlib/2and3/xml/parsers/expat/__init__.pyi index 670e56106..73f3758c6 100644 --- a/stdlib/2and3/xml/parsers/expat/__init__.pyi +++ b/stdlib/2and3/xml/parsers/expat/__init__.pyi @@ -1,75 +1 @@ -from typing import List, Tuple, Optional, Callable, Any, Protocol, Union, Dict, Text - -import pyexpat.errors as errors -import pyexpat.model as model - -EXPAT_VERSION: str # undocumented -version_info: Tuple[int, int, int] # undocumented -native_encoding: str # undocumented -features: List[Tuple[str, int]] # undocumented - -class ExpatError(Exception): - code: int - lineno: int - offset: int - -error = ExpatError - -class _Reader(Protocol): - def read(self, length: int) -> bytes: ... - -XML_PARAM_ENTITY_PARSING_NEVER: int -XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int -XML_PARAM_ENTITY_PARSING_ALWAYS: int - -_Model = Tuple[int, int, Optional[str], tuple] - -class XMLParserType(object): - def Parse(self, data: Union[Text, bytes], isfinal: bool = ...) -> int: ... - def ParseFile(self, file: _Reader) -> int: ... - def SetBase(self, base: Text) -> None: ... - def GetBase(self) -> Optional[str]: ... - def GetInputContext(self) -> Optional[bytes]: ... - def ExternalEntityParserCreate(self, context: Optional[Text], encoding: Text = ...) -> XMLParserType: ... - def SetParamEntityParsing(self, flag: int) -> int: ... - def UseForeignDTD(self, flag: bool = ...) -> None: ... - buffer_size: int - buffer_text: bool - buffer_used: int - namespace_prefixes: bool # undocumented - ordered_attributes: bool - specified_attributes: bool - ErrorByteIndex: int - ErrorCode: int - ErrorColumnNumber: int - ErrorLineNumber: int - CurrentByteIndex: int - CurrentColumnNumber: int - CurrentLineNumber: int - XmlDeclHandler: Optional[Callable[[str, Optional[str], int], Any]] - StartDoctypeDeclHandler: Optional[Callable[[str, Optional[str], Optional[str], bool], Any]] - EndDoctypeDeclHandler: Optional[Callable[[], Any]] - ElementDeclHandler: Optional[Callable[[str, _Model], Any]] - AttlistDeclHandler: Optional[Callable[[str, str, str, Optional[str], bool], Any]] - StartElementHandler: Optional[Union[ - Callable[[str, Dict[str, str]], Any], - Callable[[str, List[str]], Any], - Callable[[str, Union[Dict[str, str]], List[str]], Any]]] - EndElementHandler: Optional[Callable[[str], Any]] - ProcessingInstructionHandler: Optional[Callable[[str, str], Any]] - CharacterDataHandler: Optional[Callable[[str], Any]] - UnparsedEntityDeclHandler: Optional[Callable[[str, Optional[str], str, Optional[str], str], Any]] - EntityDeclHandler: Optional[Callable[[str, bool, Optional[str], Optional[str], str, Optional[str], Optional[str]], Any]] - NotationDeclHandler: Optional[Callable[[str, Optional[str], str, Optional[str]], Any]] - StartNamespaceDeclHandler: Optional[Callable[[str, str], Any]] - EndNamespaceDeclHandler: Optional[Callable[[str], Any]] - CommentHandler: Optional[Callable[[str], Any]] - StartCdataSectionHandler: Optional[Callable[[], Any]] - EndCdataSectionHandler: Optional[Callable[[], Any]] - DefaultHandler: Optional[Callable[[str], Any]] - DefaultHandlerExpand: Optional[Callable[[str], Any]] - NotStandaloneHandler: Optional[Callable[[], int]] - ExternalEntityRefHandler: Optional[Callable[[str, Optional[str], Optional[str], Optional[str]], int]] - -def ErrorString(errno: int) -> str: ... -def ParserCreate(encoding: Optional[Text] = ..., namespace_separator: Optional[Text] = ...) -> XMLParserType: ... +from pyexpat import * diff --git a/stdlib/2and3/xml/parsers/expat/errors.pyi b/stdlib/2and3/xml/parsers/expat/errors.pyi index 6cde43e3b..e22d769ec 100644 --- a/stdlib/2and3/xml/parsers/expat/errors.pyi +++ b/stdlib/2and3/xml/parsers/expat/errors.pyi @@ -1,44 +1 @@ -import sys -from typing import Dict - -if sys.version_info >= (3, 2): - codes: Dict[str, int] - messages: Dict[int, str] - -XML_ERROR_ABORTED: str -XML_ERROR_ASYNC_ENTITY: str -XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: str -XML_ERROR_BAD_CHAR_REF: str -XML_ERROR_BINARY_ENTITY_REF: str -XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING: str -XML_ERROR_DUPLICATE_ATTRIBUTE: str -XML_ERROR_ENTITY_DECLARED_IN_PE: str -XML_ERROR_EXTERNAL_ENTITY_HANDLING: str -XML_ERROR_FEATURE_REQUIRES_XML_DTD: str -XML_ERROR_FINISHED: str -XML_ERROR_INCOMPLETE_PE: str -XML_ERROR_INCORRECT_ENCODING: str -XML_ERROR_INVALID_TOKEN: str -XML_ERROR_JUNK_AFTER_DOC_ELEMENT: str -XML_ERROR_MISPLACED_XML_PI: str -XML_ERROR_NOT_STANDALONE: str -XML_ERROR_NOT_SUSPENDED: str -XML_ERROR_NO_ELEMENTS: str -XML_ERROR_NO_MEMORY: str -XML_ERROR_PARAM_ENTITY_REF: str -XML_ERROR_PARTIAL_CHAR: str -XML_ERROR_PUBLICID: str -XML_ERROR_RECURSIVE_ENTITY_REF: str -XML_ERROR_SUSPENDED: str -XML_ERROR_SUSPEND_PE: str -XML_ERROR_SYNTAX: str -XML_ERROR_TAG_MISMATCH: str -XML_ERROR_TEXT_DECL: str -XML_ERROR_UNBOUND_PREFIX: str -XML_ERROR_UNCLOSED_CDATA_SECTION: str -XML_ERROR_UNCLOSED_TOKEN: str -XML_ERROR_UNDECLARING_PREFIX: str -XML_ERROR_UNDEFINED_ENTITY: str -XML_ERROR_UNEXPECTED_STATE: str -XML_ERROR_UNKNOWN_ENCODING: str -XML_ERROR_XML_DECL: str +from pyexpat.errors import * diff --git a/stdlib/2and3/xml/parsers/expat/model.pyi b/stdlib/2and3/xml/parsers/expat/model.pyi index f357cf651..d8f44b47c 100644 --- a/stdlib/2and3/xml/parsers/expat/model.pyi +++ b/stdlib/2and3/xml/parsers/expat/model.pyi @@ -1,11 +1 @@ -XML_CTYPE_ANY: int -XML_CTYPE_CHOICE: int -XML_CTYPE_EMPTY: int -XML_CTYPE_MIXED: int -XML_CTYPE_NAME: int -XML_CTYPE_SEQ: int - -XML_CQUANT_NONE: int -XML_CQUANT_OPT: int -XML_CQUANT_PLUS: int -XML_CQUANT_REP: int +from pyexpat.model import * diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 249045428..f63dcc86e 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -10,9 +10,6 @@ consistent_files = [ {'stdlib/2/builtins.pyi', 'stdlib/2/__builtin__.pyi'}, {'stdlib/2/SocketServer.pyi', 'stdlib/3/socketserver.pyi'}, {'stdlib/2/os2emxpath.pyi', 'stdlib/2/posixpath.pyi', 'stdlib/2/ntpath.pyi', 'stdlib/2/macpath.pyi'}, - {'stdlib/2and3/pyexpat/__init__.pyi', 'stdlib/2and3/xml/parsers/expat/__init__.pyi'}, - {'stdlib/2and3/pyexpat/errors.pyi', 'stdlib/2and3/xml/parsers/expat/errors.pyi'}, - {'stdlib/2and3/pyexpat/model.pyi', 'stdlib/2and3/xml/parsers/expat/model.pyi'}, {'stdlib/3/ntpath.pyi', 'stdlib/3/posixpath.pyi', 'stdlib/3/macpath.pyi', 'stdlib/3/posixpath.pyi'}, {'stdlib/3/enum.pyi', 'third_party/2/enum.pyi'}, {'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'},