Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

provide style option on "add import" #1715

Open

Description

right now, add import (#1656) has one fixed style when invoked for dotted name
ex) from x import y

we might consider providing style options so that users can decide between
from x import y and import x.y

Activity

  1. heejaechang commented on Oct 24, 2019

    @heejaechang
    Author

    Tyreke White (@Anapo14) Steve Dower (@zooba) Brett Cannon (@brettcannon) is making the feature default to "from x import y" okay?

  2. brettcannon commented on Oct 24, 2019

    @brettcannon
    Member

    I think it depends on how the user triggered the automatic fix. If they used a name which would require a from import then use that, otherwise don't. I think adding style options isn't necessary for an MVP and will simply complicate things. I would wait until this goes live to see if people ask for such a feature.

  3. heejaechang commented on Oct 24, 2019

    @heejaechang
    Author

    Brett Cannon (@brettcannon) can you provide some examples on when you think we should provide import x.y and when we should provide from x import y ?

    and do you think it is something we can change later or must be in at the initial feature implementation?

    …

    so far, what I have in mind if we do this is

    if what we are importing is module, always use
    import x.y
    (one issue is we might not know "y" is module if "y" is declared from import statement in other module unless the module is already loaded by users and analyzed)

    if there is already "from x import z", then do
    from x import y, z.

    for other cases, use
    from x import y

  4. brettcannon commented on Oct 25, 2019

    @brettcannon
    Member

    Use from x import y when someone types y and so you have to do a from import. If x is already imported and the user types x.y then do import x.y.

    It's starting to sound like Tyreke White (@Anapo14) might need to expand/clarify the spec.

  5. Anapo14 commented on Oct 28, 2019

    @Anapo14
    Contributor

    Use from x import y when someone types y and so you have to do a from import. If x is already imported and the user types x.y then do import x.y.

    It's starting to sound like Tyreke White (@Anapo14) might need to expand/clarify the spec.

    I agree with Brett here on default import style.

  6. heejaechang commented on Oct 28, 2019

    @heejaechang
    Author

    I will do this polishing (using different import style based on context) as separate PR. leave all opinions on this issue so that I can consider those when I implement those improvements

  7. heejaechang commented on Oct 28, 2019

    @heejaechang
    Author

    tagging Jude Kavalam (@judej) for awareness.

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

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions