From 08744962b7a93a8bb2f1308d8dd528bee33d102b Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Mon, 19 Feb 2024 15:44:05 +0000 Subject: [PATCH] Add missing public class attributes, properties and methods for ``_LogEntry`` and ``_ErrorLog`` --- lxml-stubs/etree.pyi | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/lxml-stubs/etree.pyi b/lxml-stubs/etree.pyi index a68b090..a0305a3 100644 --- a/lxml-stubs/etree.pyi +++ b/lxml-stubs/etree.pyi @@ -24,7 +24,7 @@ from typing import ( overload, ) -from typing_extensions import Literal, Protocol, SupportsIndex, TypeAlias, TypeGuard +from typing_extensions import Literal, Protocol, Self, SupportsIndex, TypeAlias, TypeGuard # dummy for missing stubs def __getattr__(name: str) -> Any: ... @@ -374,7 +374,7 @@ class CustomElementClassLookup(FallbackElementClassLookup): class _BaseParser: def __getattr__(self, name: str) -> Any: ... # Incomplete - def copy(self) -> _BaseParser: ... + def copy(self) -> Self: ... def makeelement( self, _tag: _TagName, @@ -578,10 +578,40 @@ def tostring( ) -> _AnyStr: ... class _LogEntry: + column: int + domain: int + level: int + line: int path: Optional[str] + type: int + @property + def domain_name(self) -> str: ... + @property + def filename(self) -> Optional[str]: ... + @property + def level_name(self) -> str: ... + @property + def message(self) -> Optional[str]: ... + @property + def type_name(self) -> str: ... + +class _BaseErrorLog: + last_error: _LogEntry + def copy(self) -> Self: ... + def receive(self, entry: _LogEntry) -> None: ... -class _ErrorLog: +class _ListErrorLog(_BaseErrorLog): def __iter__(self) -> Iterator["_LogEntry"]: ... + def filter_domains(self, domains: Union[int, Iterable[int]]) -> Self: ... + def filter_from_errors(self) -> Self: ... + def filter_from_fatals(self) -> Self: ... + def filter_from_level(self, level: int) -> Self: ... + def filter_from_warnings(self) -> Self: ... + def filter_levels(self, levels: Union[int, Iterable[int]]) -> Self: ... + def filter_types(self, types: Union[int, Iterable[int]]) -> Self: ... + +class _ErrorLog(_ListErrorLog): + def clear(self) -> None: ... class Error(Exception): ...