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: ...
