Skip to content

Commit

Permalink
Use recursion in the _TagSelector collection hint
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpieters committed May 4, 2023
1 parent 4407297 commit beae266
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions lxml-stubs/etree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ _AnySmartStr = Union[
]
_TagName = Union[str, bytes, QName]
# _TagSelector also allows Element, Comment, ProcessingInstruction
_TagSelector = Union[
str,
bytes,
QName,
Collection[Any], # really Collection[_TagSelector]
Any,
]
_TagSelector = Union[_TagName, Collection[_TagSelector], Any]
# XPath object - http://lxml.de/xpathxslt.html#xpath-return-values
_XPathObject = Union[
bool,
Expand Down
2 changes: 1 addition & 1 deletion test-data/test-etree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
main: |
from lxml import etree
element = etree.Element("foo")
reveal_type(element.iterchildren) # N: Revealed type is "def (tag: Union[builtins.str, builtins.bytes, lxml.etree.QName, typing.Collection[Any], Any, None] =, *tags: Union[builtins.str, builtins.bytes, lxml.etree.QName, typing.Collection[Any], Any], *, reversed: builtins.bool =) -> typing.Iterator[lxml.etree._Element]"
reveal_type(element.iterchildren) # N: Revealed type is "def (tag: Union[Union[builtins.str, builtins.bytes, lxml.etree.QName], typing.Collection[Union[builtins.str, builtins.bytes, lxml.etree.QName, typing.Collection[...], ...]], Any, None] =, *tags: Union[builtins.str, builtins.bytes, lxml.etree.QName, typing.Collection[...], ...], *, reversed: builtins.bool =) -> typing.Iterator[lxml.etree._Element]"
result = element.iterchildren("my-attr")
reveal_type(result) # N: Revealed type is "typing.Iterator[lxml.etree._Element]"
Expand Down

0 comments on commit beae266

Please sign in to comment.