Skip to content

xml package suggests submodules being available ... they're not #6523

Closed
@ewerybody

Description

@ewerybody

I was writing up an Issue on the Pylance project as I found a built-ins-example of my seen behavior in question which is the xml package with its stub here:

import xml.parsers as parsers

So a submodule is imported marked as exported publicly there right away. Now my issue:

I understand that one can import submodules like import xml.parsers and such ... but
If you actually import just xml there is no xml.parsers!

>>> import xml
>>> xml.parsers
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'xml' has no attribute 'parsers'

The real file actually hints about 3 more submodules which are also never there on basic xml import.
(Edit: yeah that's intended! __all__ is just about broad imports! Pardon me)

Am I mistaken that the stub and the __all__ declaration suggests that this submodule would be available?
Is this a historic thing to help auto-completers along? I'd think type-checkers are much smarter nowadays.
But maybe I'm just missing something here :)
cheers:
ëRiC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions