Skip to content

New analyser: better processing of import cycles with star imports #7141

Closed

Description

@ilevkivskyi

Consider this test case:

[case testClassDeferredStar]
import lib
[file lib.py]
from other import *

class C:
    x: int
[file other.py]
import lib

Currently the order of processing targets is like this:

  • lib
  • other
  • lib
  • __main__

I think it should be possible to process such SCC without deferral at all. Couple ideas to achieve this:

  • Better ordering of targets within SCC
  • Make missing_names act per namespace (to avoid extra deferral in more complex scenarios)

Activity

  1. added
    semantic-analyzer
    on Jul 3, 2019
  2. ilevkivskyi commented on Jul 3, 2019

    @ilevkivskyi
    MemberAuthor

    Currently this affects two plugin test cases testTypeInAttrDeferredStar and testTypeInDataclassDeferredStar.

  3. self-assigned this
    on Jul 4, 2019
  4. JukkaL commented on Jul 4, 2019

    @JukkaL
    Collaborator

    It looks like we generally process modules in a very sub-optimal order. I'll see what happens if we reverse the order.

  5. JukkaL commented on Jul 8, 2019

    @JukkaL
    Collaborator

    Fixed by #7163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs discussionpriority-0-highsemantic-analyzer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions