Skip to content
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

xml typing incomplete #6886

Open
surgura opened this issue Jan 10, 2022 · 2 comments
Open

xml typing incomplete #6886

surgura opened this issue Jan 10, 2022 · 2 comments
Labels
help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: incomplete Annotations or sub-modules missing from an existing package or module

Comments

@surgura
Copy link

surgura commented Jan 10, 2022

While using mypy wit typeshed I noticed that some xml.minidom functions return values are annotated as .... I am no guru with the typing system, but I think here it is used as a placeholder. E.g. the createDocument returns a Document instance(I validated this with the std implementation code on my side), but is annotated with an ellipsis.

Are these simply still missing or is this on purpose? Excuse me if there is a typeshed todo list somewhere that I missed.

@srittau srittau added the stubs: incomplete Annotations or sub-modules missing from an existing package or module label Jan 10, 2022
@srittau
Copy link
Collaborator

srittau commented Jan 10, 2022

The xml stubs are indeed incomplete. The marker for a missing return type is not ..., though, but the missing -> operator. For example:

def createDocumentFragment(self): ...  # no return type
def createDocumentFragment(self) -> Whatever: ...  # with return type

Any improvements are welcome!

@surgura
Copy link
Author

surgura commented Jan 10, 2022

I see, that makes sense. I can probably add typing for a few functions, but I am not very experienced with this module.

@AlexWaygood AlexWaygood added the help wanted An actionable problem of low to medium complexity where a PR would be very welcome label Aug 27, 2022
zackw added a commit to zackw/typeshed that referenced this issue Oct 13, 2023
This patch completes all the type stubs for xml.dom.minidom.  I did
not look at the rest of the xml.dom directory except as required to
make the typing of minidom complete, so it probably doesn’t completely
resolve python#6886.

xml.dom.minidom is very poorly documented—its authors seem to have
assumed that one could refer to the W3C DOM spec.  But at the same
time the implementation diverges significantly from the spec, so I
do not have complete confidence in all the type annotations.  Still,
it should be an improvement on what’s there now.

The following commands now pass with no errors when executed from the
top of the typeshed tree:

```sh
mypy --custom-typeshed-dir . --strict --warn-incomplete-stub \
     -m xml.dom.minidom
stubtest --custom-typeshed-dir . xml.dom.minidom
```

**However**, attempting to do the same for xml.dom.minicompat produces
the following error:

```sh
mypy --custom-typeshed-dir . --strict --warn-incomplete-stub \
     -m xml.dom.minicompat
stdlib/xml/dom/minicompat.pyi:11: error: All bases of a protocol must be protocols  [misc]
```

I don’t know how to fix this, because in the implementation,
EmptyNodeList is not a subclass of NodeList, therefore if I don’t make
NodeList a protocol, then xml.dom.minidom.Childless fails stubtest.
This patch probably should not land until this is resolved.  Any
advice you could give would be welcome.
@srittau srittau removed the topic-xml label Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted An actionable problem of low to medium complexity where a PR would be very welcome stubs: incomplete Annotations or sub-modules missing from an existing package or module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants