-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: add missing type stubs for xml.dom.minidom.DOMImplementation
, where possible
#8556
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :)
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.
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.DOMImplementation
based 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