Skip to content

Commit

Permalink
Fix return of html.fragments_fromstring
Browse files Browse the repository at this point in the history
If the string contains leading text, the first element of the returned
list will be a `str`. Only if `no_leading_text=True` was specified can
we guarantee that there will be no `str` fragment at the beginning.
  • Loading branch information
Wuestengecko committed Apr 4, 2024
1 parent 5ef5804 commit d06edf9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lxml-stubs/html/_parse.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from typing import Any, Iterable, MutableMapping
from typing import Any, Iterable, Literal, MutableMapping, overload

if sys.version_info >= (3, 10):
from typing import TypeAlias
Expand Down Expand Up @@ -122,13 +122,22 @@ def document_fromstring(
*,
base_url: str | None = ...,
) -> HtmlElement: ...
@overload
def fragments_fromstring(
html: _AnyStr,
no_leading_text: bool = ...,
no_leading_text: Literal[True],
base_url: str | None = ...,
parser: _HtmlElemParser | None = ...,
**kw: Unused,
) -> list[HtmlElement]: ...
@overload
def fragments_fromstring(
html: _AnyStr,
no_leading_text: Literal[False] = ...,
base_url: str | None = ...,
parser: _HtmlElemParser | None = ...,
**kw: Unused,
) -> list[str | HtmlElement]: ...
def fragment_fromstring(
html: _AnyStr,
create_parent: bool = ...,
Expand Down

0 comments on commit d06edf9

Please sign in to comment.