Skip to content

Commit

Permalink
Remove deprecated methods. (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR authored Jan 27, 2025
1 parent a4f42b5 commit 076ee4a
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
TypeVar,
Union,
)
from warnings import warn

import jmespath
from lxml import etree, html
Expand Down Expand Up @@ -282,18 +281,6 @@ def attrib(self) -> Mapping[str, str]:
return x.attrib
return {}

def remove(self) -> None: # type: ignore[override]
"""
Remove matched nodes from the parent for each element in this list.
"""
warn(
"Method parsel.selector.SelectorList.remove is deprecated, please use parsel.selector.SelectorList.drop method instead",
category=DeprecationWarning,
stacklevel=2,
)
for x in self:
x.remove()

def drop(self) -> None:
"""
Drop matched nodes from the parent for each element in this list.
Expand Down Expand Up @@ -770,35 +757,6 @@ def remove_namespaces(self) -> None:
# remove namespace declarations
etree.cleanup_namespaces(self.root)

def remove(self) -> None:
"""
Remove matched nodes from the parent element.
"""
warn(
"Method parsel.selector.Selector.remove is deprecated, please use parsel.selector.Selector.drop method instead",
category=DeprecationWarning,
stacklevel=2,
)
try:
parent = self.root.getparent()
except AttributeError:
# 'str' object has no attribute 'getparent'
raise CannotRemoveElementWithoutRoot(
"The node you're trying to remove has no root, "
"are you trying to remove a pseudo-element? "
"Try to use 'li' as a selector instead of 'li::text' or "
"'//li' instead of '//li/text()', for example."
)

try:
parent.remove(self.root)
except AttributeError:
# 'NoneType' object has no attribute 'remove'
raise CannotRemoveElementWithoutParent(
"The node you're trying to remove has no parent, "
"are you trying to remove a root element?"
)

def drop(self) -> None:
"""
Drop matched nodes from the parent element.
Expand Down

0 comments on commit 076ee4a

Please sign in to comment.