Skip to content

Support partial/incomplete stubs #5

Closed

Description

@JukkaL

Maybe we should have a way of specifying a stub as (potentially) incomplete for libraries that are changing rapidly and there is no dedicated maintainer for the stub. In cases like this a type checker / inferencer would either treat all names as implicitly defined in the module (with type Any), or it could parse the actual main Python implementation and merge the annotations from the stubs to the full module AST.

Activity

  1. gvanrossum commented on Jan 26, 2016

    @gvanrossum
    Member

    Hm. Do you mind if I close this? It feels kind of over-complicated. In practice people seem to be okay with contributing a PR to the stubs when they run into this.

  2. matthiaskramm commented on Feb 11, 2016

    @matthiaskramm
    Contributor

    It's useful to be able to say "this module exists" without actually having to describe in detail what it contains. pytype uses it to describe inference results for things that aren't in typeshed and can't be autogenerated (like C extensions) without having them cause an import error.
    pytype is going to use

    def __getattr__(name) -> Any: ...
    

    on the pyi module level. Does that sound like a reasonable way to express this, and is that something we should allow in typeshed?

  3. gvanrossum commented on Feb 11, 2016

    @gvanrossum
    Member

    That's a unique thing at the toplevel (though people have asked for it before so they can overload module attributes) but it's syntactically nothing new, so I'm fine with it. Can you propose a sentence to add to PEP 484 about this? Or do you think it can be left out of there and just be a pytype/mypy extension to the PEP? (Well I guess it would be nice if PyCharm also understood it.)

  4. JelleZijlstra commented on May 11, 2018

    @JelleZijlstra
    Member

    PEP 484 now specifies module-level __getattr__ and mypy supports it, so this can be closed.

  5. added a commit that references this issue on Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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