Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix _ErrorLog not iterable #100

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading