You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently namespaces type in find method is defined as _StrictNSMap = Mapping[str, str], which causes mypy error being reported when default namespace (None key) is used. Is it correct?
lxml supports 2 ways of specifying the default namespace: None and an empty string (""). Because nsmap attribute of Element shows the default namespace under None key, I'd expect find to also be allowed to use this format.
Small snippet from ipython:
In [13]: z = lxml.etree.XML("<a><b xmlns='foo'/></a>")
In [14]: z.find('./b')
In [15]: z.find('./b', namespaces={None: "foo"})
Out[15]: <Element {foo}b at 0x7f6df2c0e480>
In [16]: z.find('./b', namespaces={"": "foo"})
Out[16]: <Element {foo}b at 0x7f6df2c0e480>
In [17]: z.find('./b', namespaces={"": "foo"}).nsmap
Out[17]: {None: 'foo'}
The text was updated successfully, but these errors were encountered:
You're correct, I have been overzealous with the namespaces dict key change. Originally it is intended to prevent silly usage like find('*', namespaces={None: "foo", "": "bar"}), but such corner cases hurts more general usage. Will fix it soon.
Currently
namespaces
type infind
method is defined as_StrictNSMap = Mapping[str, str]
, which causes mypy error being reported when default namespace (None
key) is used. Is it correct?lxml supports 2 ways of specifying the default namespace:
None
and an empty string (""
). Becausensmap
attribute of Element shows the default namespace underNone
key, I'd expectfind
to also be allowed to use this format.Small snippet from ipython:
The text was updated successfully, but these errors were encountered: