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

Prevent isort from running on virtualenv files via editor? #1500

Closed
pikeas opened this issue Sep 25, 2020 · 3 comments
Closed

Prevent isort from running on virtualenv files via editor? #1500

pikeas opened this issue Sep 25, 2020 · 3 comments
Labels
integration question Further information is requested

Comments

@pikeas
Copy link

pikeas commented Sep 25, 2020

[tool.isort]
profile = "black"
verbose = true

I have VS Code configured to use isort locally:

{
  ...
  "python.sortImports.path": "${workspaceFolder}/.venv/bin/isort",
}

When saving a file in the virtualenv directory, isort unexpectedly runs. Here's what VS Code's output pane shows:

> <project path>/.venv/bin/isort - --diff
cwd: <project path>/.venv/lib/python3.8/site-packages/<some module>
Error: Invalid patch string: else-type place_module for <some import> returned STDLIB

The actual error seems potentially related to #1469 but I have confirmed that the version of isort in the virtualenv is the latest 5.5.3.

However, the surprising thing is that isort shouldn't run at all. It doesn't seem to consider https://pycqa.github.io/isort/docs/configuration/options/#skip . I've tried adding skip_gitignore as well (which includes .venv/, to no avail.

@pikeas pikeas changed the title Prevent isort from running on .virtualenv files via editor? Prevent isort from running on virtualenv files via editor? Sep 25, 2020
@pikeas
Copy link
Author

pikeas commented Sep 25, 2020

Update: this is a bit of a Heisenbug, behavior is different with and without verbose = true! I imagine this is because VS Code isn't equipped to handle the additonal verbose output.

With verbose off, there's no error, but isort continues to (unexpectedly) run.

@char101
Copy link

char101 commented Sep 26, 2020

isort is run via stdin thus it has no concept of the file path. When run like that it should be the responsibility of the editor/plugin to skip files.

@timothycrosley timothycrosley added integration question Further information is requested labels Sep 27, 2020
@timothycrosley
Copy link
Member

@char101 is correct regarding it being unaware of path - however you should be able to configure vs code to tell it the path if you would like to use a normal isort config, using setting path: https://pycqa.github.io/isort/docs/configuration/options/#settings-path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants