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

Automatic import organisation inconsistent between type hints and action on save #443

Open
KarimAED opened this issue May 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@KarimAED
Copy link

Describe the bug
Ruff runs as an action on save, even if I don't tell it to. I literally have all boxes in the Ruff settings page unchecked. Worst of all, however, the context action for organizing imports, and the action on save disagree on the correct import formatting for the snippet:

from pathlib import Path
from typing import Any

import click
import matplotlib.pyplot as plt
import numpy as np

from my_package.utils import MyObject

With one suggesting a line between numpy and my_package imports while the other keeps removing the line. This only happens when I use top-level imports from my_package, i.e. the issue is resolved with from .utils import.

To Reproduce
Steps to reproduce the behavior:

  1. Install ruff plugin
  2. Deactivate all actions in the Settings>Tools>Ruff pane
  3. Still get Ruff actions on save
  4. Create a project structure where you import files from a top-level package
  5. Actions on save and code annotations disagree

Expected behavior
When I turn off Run ruff on save and Run ruff when reformat code, Ruff should never run automatically to fix my code. Also, the action on save is incorrect in this case, I believe, in suggesting removing the line between imports from my_package and third party software. This should be fixed.

Screenshots

This is my ruff tool pane:

image

This is what the action on save formats it to (Ruff thinks this is wrong):

image

This is what it should look like:

image

Environments (please complete the following information):

  • IDE: PyCharm Professional 2024.1.1
  • OS: Debian Bookworm 12.5
  • Ruff Version: 0.4.4
  • Plugin version: 0.0.33

Additional context
Add any other context about the problem here.

@koxudaxi koxudaxi added the bug Something isn't working label May 30, 2024
@hexvolt
Copy link

hexvolt commented Jul 25, 2024

@KarimAED @koxudaxi this might be a duplicate of #422

@KarimAED
Copy link
Author

@hexvolt not sure if we are encountering the exact same behaviour, but it might be a very similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants