fix: add missing type stubs for xml.dom.minidom.DOMImplementation, where possible#8556
fix: add missing type stubs for xml.dom.minidom.DOMImplementation, where possible#8556AlexWaygood merged 3 commits intopython:masterfrom kkirsche:fix/6886
xml.dom.minidom.DOMImplementation, where possible#8556Conversation
This comment has been minimized.
This comment has been minimized.
| def createDocumentType(self, qualifiedName: str | None, publicId, systemId): ... | ||
| def getInterface(self, feature): ... | ||
| def hasFeature(self, feature: str, version: str | None) -> bool: ... | ||
| def createDocument(self, namespaceURI: str | None, qualifiedName: str | None, doctype: DocumentType | None) -> Document: ... |
There was a problem hiding this comment.
I couldn't find definitive evidence for this in the source code, but the documentation for this method confirms this type annotation. Looks good.
There was a problem hiding this comment.
I had been trying to use https://cs.github.com/?scopeName=All+repos&scope=&q=repo%3Apython%2Fcpython+path%3ALib%2Fxml%2Fdom+%22.createDocument%28%22 to work backwards through what calls were being used and comparing it to the documentation as my way of trying to find evidence, if that helps
There was a problem hiding this comment.
Oh, that is helpful, thanks! Especially with xml, it's sometimes pretty difficult to figure out the types just by studying the source code, so hints as to how you figured out non-obvious types are definitely appreciated :)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood
left a comment
There was a problem hiding this comment.
Nice! Always great to get better types for our xml stubs — I think we probably all agree it's the weakest area in our stdlib stubs at the moment :)
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
For whatever reason, security standards like OpenSCAP often default to XML standards so I end up in either |
|
You can see here that there are a number of typeshed/pyrightconfig.stricter.json Lines 9 to 95 in fb62cca Ideally there wouldn't be any stdlib files on that list :) The main difference between the basic pyright settings in (Note that that doesn't mean that we should go adding |
(Having said that, I wouldn't bother with trying to fix the |
This adds additional details to
xml.dom.minidom.DOMImplementationbased on what I am able to determine from:https://github.com/python/cpython/blob/main/Lib/xml/dom/minidom.py
This begins to address #6886