Skip to content

Support relative imports of the package under development #75

Open
@lyz-code

Description

@lyz-code

Description

When developing a package I prefer to use relative imports over absolute ones to avoid loop dependencies. Right now autoimport only uses absolute imports, so I need to remove the absolute reference and convert it to relative.

Possible Solution

It's not easy to solve, as we can't take into account the relative position of the file we're fixing regarding the rest of the project, as some of the tools that use autoimport (ALE for vim integration), copies the file to a temporal directory and applies the fixer there.

So we would need to:

  • Deduce the location of the file regarding the package. Either by analyzing the objects of the file we're fixing and searching them in the package, or by analyzing existent relative import statements.
  • Get the absolute path to the object that we need to import
  • Get the relative path from the file location to the desired object

Additional context

Related Issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions