1
1
mirror of https://git.launchpad.net/beautifulsoup synced 2025-10-06 00:12:49 +02:00

Overloaded find_all_previous.

This commit is contained in:
Leonard Richardson
2025-09-14 12:56:33 -04:00
parent 222984beae
commit f58228ff0b
2 changed files with 26 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
* find_next()
* find_next_sibling()
* find_previous()
* find_all_previous()
* find_previous_sibling()
* __call__() (i.e. calling a Tag as if it were a function)
@@ -31,7 +32,6 @@
* find_all_next()
* find_next_siblings()
* find_all_previous()
* find_previous_siblings()
This will hopefully be improved in a future version of Beautiful Soup.

View File

@@ -952,6 +952,30 @@ class PageElement(object):
findPrevious = _deprecated_function_alias("findPrevious", "find_previous", "3.0.0")
@overload
def find_all_previous( # pyright: ignore [reportOverlappingOverload]
self,
name: _FindMethodName = None,
attrs: Optional[_StrainableAttributes] = None,
string: None = None,
limit: Optional[int] = None,
_stacklevel: int = 2,
**kwargs: _StrainableAttribute,
) -> _SomeTags:
...
@overload
def find_all_previous(
self,
name: None = None,
attrs: None = None,
string: _StrainableString = "",
limit: Optional[int] = None,
_stacklevel: int = 2,
**kwargs: _StrainableAttribute,
) -> _SomeNavigableStrings:
...
def find_all_previous(
self,
name: _FindMethodName = None,
@@ -960,7 +984,7 @@ class PageElement(object):
limit: Optional[int] = None,
_stacklevel: int = 2,
**kwargs: _StrainableAttribute,
) -> _QueryResults:
) -> Union[_SomeTags,_SomeNavigableStrings,_QueryResults]:
"""Look backwards in the document from this `PageElement` and find all
`PageElement` that match the given criteria.