-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
refactor: expand types in xml module #8590
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Also, some of the parameter names of node are misleading, as the isinstance checks are checking for Attr nodes specifically, which is deceptive on a first pass: |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I have a few comments.
@@ -70,7 +73,7 @@ class Attr(Node): | |||
value: str | |||
prefix: Any | |||
def __init__( | |||
self, qName: str, namespaceURI: str | None = ..., localName: Any | None = ..., prefix: Any | None = ... | |||
self, qName: str, namespaceURI: str | None = ..., localName: str | None = ..., prefix: Any | None = ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The localName
argument is actually ignored: https://github.com/python/cpython/blob/18b1782192f85bd26db89f5bc850f8bee4247c1a/Lib/xml/dom/minidom.py#L355.
Seems like it wants a if localName is not None: self._localName = localName
. Are you interested in contributing that to CPython?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
X-Ref: python/typeshed#8590 (comment) This adds a missing assignment to `_localName`
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comments were addressed, thanks. Still need to resolve @AlexWaygood's concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't reviewed in detail, but my concerns have been addressed, and I'll defer to @JelleZijlstra on the rest! :)
This comment has been minimized.
This comment has been minimized.
1 similar comment
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
…Attr` (#96176) X-Ref: python/typeshed#8590 (comment) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
…nidom.Attr` (python#96176) X-Ref: python/typeshed#8590 (comment) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
encoding
changed fromAny | None
tostr | None
as it's used as a parameter to TextIOWrapperstandalone
changed fromAny | None
tobool | None
per https://docs.python.org/3/library/xml.dom.minidom.html#xml.dom.minidom.Node.writexmllocalName
changed fromAny | None
tostr | None
asNode
'slocalName
property returnsstr | None
object
as they useid
to do the comparisons, not object specific behavior: https://github.com/python/cpython/blob/main/Lib/xml/dom/minidom.py#L534TypeInfo
partially typed based on https://cs.github.com/python/cpython/blob/5ed584cb6b4e544d307f2f1b6f28667078cc20af/Lib/xml/dom/expatbuilder.py?q=repo%3Apython%2Fcpython+path%3ALib%2Fxml%2F+TypeInfo#L47-L58get*Item
check with a try / except: https://github.com/python/cpython/blob/main/Lib/xml/dom/minidom.py#L571