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

Ruff format doesn't sort imports, nothing changed (E402) #14243

Closed
zakimimit opened this issue Nov 10, 2024 · 3 comments
Closed

Ruff format doesn't sort imports, nothing changed (E402) #14243

zakimimit opened this issue Nov 10, 2024 · 3 comments
Labels
question Asking for support or clarification

Comments

@zakimimit
Copy link

zakimimit commented Nov 10, 2024

Hello

Ruff format doesn't sort imports, nothing changed

I use Vscode Extenstion Ruff v2024.54.0

ruff.toml

[lint]
extend-select = ["I","N","F","E","W","R","C90","UP","SIM","E402"]

extend-ignore = ["E501"]

ignore = ["E501","F403","F405"]


This does not work
Module-level import not at top of file
Module-import-not-at-top-of-file (E402)

I try several times, nothing works

image

image

I hope you can fix it

@charliermarsh
Copy link
Member

Not all errors are auto-fixable. Can you be more specific about what you're trying to do?

@charliermarsh charliermarsh added the question Asking for support or clarification label Nov 10, 2024
@zakimimit
Copy link
Author

Not all errors are auto-fixable. Can you be more specific about what you're trying to do?

For example

from flask_wtf import FlaskForm
from wtforms import (
    SubmitField,
)

class SetPriceForm(FlaskForm):
    submit = SubmitField("Set Prices")


import pyotp

class SeForm(FlaskForm):
    submit = SubmitField("Set ")

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not self.is_submitted():
            self.auth_key.data = pyotp.random_base32()

The import pyotp is not fixed
It should be fixed and go up with othor import

Like this


import pyotp

from flask_wtf import FlaskForm
from wtforms import (
    SubmitField,
)

@MichaReiser
Copy link
Member

The reason this isn't working as expected is because ruff doesn't support the float-to-top isort options. We track that feature in #1251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

3 participants