Skip to content

stubgen often generates incorrect imports #1782

Closed

Description

@Diggsey

In examples like the following:

from x import y

Stubgen will often lose the from x, and simply generate an import like:

import y

Activity

  1. JukkaL commented on Jul 1, 2016

    @JukkaL
    Collaborator

    Can you give a full, self-contained example where this happens?

  2. Diggsey commented on Jul 1, 2016

    @Diggsey
    Author
    # stubtest/__init__.py
    # stubtest/a.py
    from . import interfaces
    
    class X(interfaces.Y):
        pass
    # stubtest/interfaces.py
    class Y:
        pass

    > stubgen stubtest.a

    # out/stubtest/a.pyi
    
    # Stubs for stubtest.a (Python 3.5)
    #
    # NOTE: This dynamically typed stub was automatically generated by stubgen.
    
    import interfaces
    
    class X(interfaces.Y): ...
  3. added this to the milestone on Jul 7, 2016
  4. removed this from the milestone on Mar 29, 2017
  5. shangxiao commented on Jul 10, 2017

    @shangxiao

    stubgen doesn't keep track of imports attempt to resolve imports with the ast; it simply adds "import foo"

  6. gvanrossum commented on Jul 10, 2017

    @gvanrossum
    Member
  7. shangxiao commented on Jul 13, 2017

    @shangxiao

    Hmm… not sure that the reference above pinged anyone, so bump: #3704

  8. dmoisset commented on Sep 25, 2017

    @dmoisset
    Contributor

    I just checked and I think #3169 solved this

  9. ilevkivskyi commented on Sep 25, 2017

    @ilevkivskyi
    Member

    Yes, it looks like this is fixed now.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions