Skip to content

Commit

Permalink
Extend _ErrorLog definitions (GH-100)
Browse files Browse the repository at this point in the history
Add missing public class attributes, properties and methods for ``_LogEntry`` and ``_ErrorLog``
  • Loading branch information
nsoranzo authored Jun 4, 2024
1 parent fc54574 commit 6832d61
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions lxml-stubs/etree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ 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: ...
Expand Down Expand Up @@ -374,7 +381,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,
Expand Down Expand Up @@ -577,7 +584,42 @@ def tostring(
inclusive_ns_prefixes: Any = ...,
) -> _AnyStr: ...

class _ErrorLog: ...
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 _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): ...

class LxmlError(Error):
Expand Down

0 comments on commit 6832d61

Please sign in to comment.