Closed GuillaumeLeGoc closed 1 month ago
I think this will only work if the required Python version is 3.11 or greater as tomllib
was added in that Python version. Can you share your pyproject.toml
? You could also run ruff
from the command-line with the --verbose
flag which will provide which category an import is in:
[2024-05-20][11:53:16][ruff_linter::rules::isort::categorize][DEBUG] Categorized 'tomllib' as Known(StandardLibrary) (KnownStandardLibrary)
👍 You can add something like:
[project]
...
requires-python = ">=3.11"
...to your pyproject.toml
, to indicate that your project only supports Python 3.11 and later. Alternatively, you can tell Ruff to treat 3.11 as your minimum supported version with:
[tool.ruff]
target-version = "py311"
Closing for now, let me know if you're continuing to see this after applying the above.
Hi, I'm using vscode on a project with a conda environment using python 3.12. The conda environment is selected in vscode. When running
Ruff: Format imports
from the command palette,tomllib
is moved with non-standard imports.Before
Ruff: Format imports
:After
Ruff: Format imports
:The issue was raised here https://github.com/astral-sh/ruff/issues/2343, and supposedly fixed here https://github.com/astral-sh/ruff/pull/2345.
System information :
Do I have to take further action to fix the problem (configuration, ...) ?
Cheers !