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

Unsafe fixes not applied on save #672

Closed
VoidSignal opened this issue Jan 21, 2025 · 1 comment
Closed

Unsafe fixes not applied on save #672

VoidSignal opened this issue Jan 21, 2025 · 1 comment

Comments

@VoidSignal
Copy link

Can't get VSCode to apply unsafe fixes on save automatically even though unsafe-fixes = true in pyproject.toml. Manually running ruff check applies all fixes as expected.

settings.json:

{
    "[python]": {
        "editor.codeActionsOnSave": {
            "source.fixAll.ruff": "explicit",
            "source.organizeImports.ruff": "explicit"
        },
        "editor.defaultFormatter": "charliermarsh.ruff",
        "editor.formatOnSave": true
    },
    "ruff.configurationPreference": "filesystemFirst",
    "ruff.importStrategy": "fromEnvironment",
    "ruff.nativeServer": "on",
}

pyproject.toml

[tool.ruff]
target-version = 'py39'
line-length = 120
fix = true
unsafe-fixes = true

[tool.ruff.lint]
select = ['ALL']
ignore = [
    'COM812',
    'D1',
    'D203',
    'D212',
    'EM101',
    'FBT',
    'FIX',
    'ISC001',
    'N812',
    'PD901',
    'RET504',
    'RUF001',
    'RUF002',
    'RUF003',
    'TD',
    'TRY003',
]

test.py

from __future__ import annotations

from collections.abc import Mapping

d: Mapping[str, str] = {}

Expected result: Mapping import is automatically moved into a newly created type-checking block.
Actual result: nothing happens.

OS: Ubuntu 22.04.5
VSCode: 1.96.4
Extension: 2025.2.0
Python: 3.9
Ruff: 0.9.2

@dhruvmanila
Copy link
Member

Thanks for the report, this is tracked in astral-sh/ruff#13960.

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

No branches or pull requests

2 participants