Skip to content

Commit

Permalink
Apply pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed Jun 14, 2024
1 parent 122c0f0 commit fd49654
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def __getitem__(
def __getstate__(self) -> None:
raise TypeError("can't pickle SelectorList objects")

def jmespath(self, query: str, *, type: Optional[str] = None, **kwargs: Any) -> "SelectorList[_SelectorType]":
def jmespath(
self, query: str, *, type: Optional[str] = None, **kwargs: Any
) -> "SelectorList[_SelectorType]":
"""
Call the ``.jmespath()`` method for each element in this list and return
their results flattened as another :class:`SelectorList`.
Expand All @@ -154,7 +156,9 @@ def jmespath(self, query: str, *, type: Optional[str] = None, **kwargs: Any) ->
selector.jmespath('author.name', options=jmespath.Options(dict_cls=collections.OrderedDict))
"""
return self.__class__(flatten([x.jmespath(query, type=type, **kwargs) for x in self]))
return self.__class__(
flatten([x.jmespath(query, type=type, **kwargs) for x in self])
)

def xpath(
self,
Expand All @@ -181,10 +185,19 @@ def xpath(
selector.xpath('//a[href=$url]', url="http://www.example.com")
"""
return self.__class__(
flatten([x.xpath(xpath, namespaces=namespaces, type=type, **kwargs) for x in self])
flatten(
[
x.xpath(xpath, namespaces=namespaces, type=type, **kwargs)
for x in self
]
)
)

def css(self, query: str, type: Optional[str] = None,) -> "SelectorList[_SelectorType]":
def css(
self,
query: str,
type: Optional[str] = None,
) -> "SelectorList[_SelectorType]":
"""
Call the ``.css()`` method for each element in this list and return
their results flattened as another :class:`SelectorList`.
Expand Down Expand Up @@ -644,7 +657,9 @@ def xpath(
]
return typing.cast(SelectorList[_SelectorType], self.selectorlist_cls(result))

def css(self: _SelectorType, query: str, type: Optional[str] = None) -> SelectorList[_SelectorType]:
def css(
self: _SelectorType, query: str, type: Optional[str] = None
) -> SelectorList[_SelectorType]:
"""
Apply the given CSS selector and return a :class:`SelectorList` instance.
Expand Down

0 comments on commit fd49654

Please sign in to comment.