selectolax icon indicating copy to clipboard operation
selectolax copied to clipboard

[Typing] `_Attributes` in .pyi stub file is missing dictionary methods like `__getitem__`

Open notypecheck opened this issue 2 years ago • 0 comments

Seems like _Attributes is missing methods from dict class, even though documentation states otherwise:

Examples
--------
>>> tree = HTMLParser("<div id='a'></div>")
>>> node = tree.css_first('div')
>>> node.attrs
<div attributes, 1 items>
>>> node.attrs['id']
'a'

Reproduction:

from selectolax.parser import HTMLParser

parser = HTMLParser("")
element = parser.css_first(".class")
print(element.attrs["some-attr"])
main.py:5:7: error: Value of type "_Attributes" is not indexable  [index]
    print(element.attrs["some-attr"])

Python version: 3.11.7 Selectolax version: 0.3.18 Mypy: 1.8.0

notypecheck avatar Jan 25 '24 13:01 notypecheck