Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(🎁) "organize imports" integration #140

Open
KotlinIsland opened this issue Apr 19, 2023 · 5 comments
Open

(🎁) "organize imports" integration #140

KotlinIsland opened this issue Apr 19, 2023 · 5 comments
Labels
enhancement New feature or request polar

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Apr 19, 2023

the vscode extension has options/commands for:

  • organize imports on save
  • fix all on save
  • a fix all command
  • format code

I think that it would be beneficial if this plugin had a separate "organise imports" option like the vscode extensions does.

See com.intellij.lang.ImportOptimizer

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@johnthagen
Copy link

This would be awesome.

My current work around is to run

$PyInterpreterDirectory$/python -m ruff check --select I --fix $FilePath$

as part of a File Watcher

Having this be a simple option to "sort imports on save" built into the plugin would be save a lot of manual configuration for each user.

@urob
Copy link

urob commented May 30, 2024

Isn't this already possible? For me the following combination of options achieves this:

  • Run ruff when the python file is saved
  • Use ruff format (Experimental) for version 0.0.289 or later
  • Enabling auto-fixing imports in the projects' pyproject.toml file:
    [tool.ruff.lint]
    select = ['I']   # add more rules here as desired
    fixable = ['I']  # add more rules here as desired

@KotlinIsland
Copy link
Contributor Author

@urob that would lead to fixing everything, which is not desirable.

@urob
Copy link

urob commented May 31, 2024

@urob that would lead to fixing everything, which is not desirable.

Not sure I follow. The I rules are just for organizing the imports. You could be even more specific and only specify I001.

I'm using something very similar to this and there aren't any additional linter fixes that are automatically applied for me.

@KotlinIsland
Copy link
Contributor Author

Oh right, yeah, read that backwards.

Your solution would lead to nothing else being fixed, which is not desirable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request polar
Projects
None yet
Development

No branches or pull requests

4 participants