rushter / selectolax

Python binding to Modest and Lexbor engines (fast HTML5 parser with CSS selectors).
MIT License
1.11k stars 68 forks source link

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

Open ThirVondukr opened 8 months ago

ThirVondukr commented 8 months ago

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