tamaroth
tamaroth

Reputation: 37

How to disable automatic linting of imported classes from modules?

In my project, I'm importing a series of different other modules/classes, for instance like this:

from my_project.filesystem import create_dir
from my_project.filesystem import file_size
from my_project.hashing import hash_from_file
from my_project.multiprocessing import max_workers_for
from my_project.multiprocessing import multiprocessing

When saving the file, Python extension automatically is linting those lines into:

from my_project.filesystem import create_dir, file_size
from my_project.hashing import hash_from_file
from my_project.multiprocessing import max_workers_for, multiprocessing

In settings, I have tried disabling auto linting:

{
    "python.linting.lintOnSave": false,
    "python.linting.enabled": false,
    "python.linting.pylintArgs": [
        "--disable=all"
    ]
}

For clarity, I prefer to have my imports separate, but now I'm faced with a daunting task to "fix the fix" before committing any changes.

Is there a way to disable this feature (bar disabling the whole extension, which works but removes other features of the extension which I'd prefer to continue using)?

Upvotes: 0

Views: 805

Answers (1)

Felix
Felix

Reputation: 6359

I think that your imports get sorted by isort. You might be able to solve the issue by passing a custom argument to it. The "force_single_line" option mentioned here seems to be what you want. To pass this configuration option to isort, add the following line to your vs code config:

"python.sortImports.args": ["-sl"]

Let me know if that solves the issue.

Upvotes: 1

Related Questions