-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
stdlib xml.etree: tags, attributes and attribute values can be QName instances #11841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…instances See e.g. the ElementTree unit tests: https://github.com/python/cpython/blob/3.12/Lib/test/test_xml_etree.py#L1195 I guess this is fairly obscure functionality. The documentation does describe the QName class, but it doesn't say much more than the bare minimum.
|
Diff from mypy_primer, showing the effect of this PR on open source code: vision (https://github.com/pytorch/vision)
+ torchvision/datasets/voc.py:219: error: Dict entry 0 has incompatible type "str | QName": "dict[Any, Any]"; expected "str": "Any" [dict-item]
+ torchvision/datasets/voc.py:223: error: Invalid index type "str | QName" for "dict[str, Any]"; expected type "str" [index]
mkdocs (https://github.com/mkdocs/mkdocs)
+ mkdocs/utils/rendering.py:72: error: Item "QName" of "str | QName" has no attribute "startswith" [union-attr]
+ mkdocs/utils/rendering.py:85: error: Incompatible return value type (got "str | QName", expected "str | None") [return-value]
+ mkdocs/structure/pages.py:337: error: Argument 1 has incompatible type "str | QName"; expected "str" [arg-type]
+ mkdocs/structure/pages.py:340: error: Argument 1 has incompatible type "str | QName"; expected "str" [arg-type]
+ mkdocs/structure/pages.py:370: error: Argument 1 to "path_to_url" of "_RelativePathTreeprocessor" has incompatible type "str | QName"; expected "str" [arg-type]
pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/junitxml.py:103: error: Argument 1 to "add_stats" of "LogXML" has incompatible type "str | QName"; expected "str" [arg-type]
boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/listing.py:410: error: Argument 1 to "AzureStat" has incompatible type "Dict[Union[str, QName, Any], Union[str, None, Any]]"; expected "Mapping[str, Any]" [arg-type]
|
|
This apparently badly breaks the openpyxl typings. I'm afraid I'm not familiar with that library and I don't understand what |
|
The main problems seems to be the |
can be undone once python/typeshed#11841 is merged
|
Going back deep into openpyxl implementation. The Not that it really helps you here since Looking at the primer results, as @srittau said, there's a lot of code out there that seems to assume some of the attributes you change can only be |
|
This is very out of date; we've since made Element generic in another PR. |
See e.g. the ElementTree unit tests:
https://github.com/python/cpython/blob/3.12/Lib/test/test_xml_etree.py#L1195
I guess this is fairly obscure functionality. The documentation does describe the QName class, but it doesn't say much more than the bare minimum.