Skip to content

isort commit hook behaving differently in integrated terminal and source control panel #9948

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

Closed
janosh opened this issue Feb 6, 2020 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@janosh
Copy link

janosh commented Feb 6, 2020

Steps to reproduce

Create a repo and install pre-commit

git init && pip install pre-commit

Create 3 files.

touch a.py b.py .pre-commit-config.yaml

containing

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/timothycrosley/isort
    rev: 4.3.21
    hooks:
      - id: isort
# a.py
a = "a"
# b.py
import tensorflow as tf  # any 3rd party import

from a import a

Install isort commit hook via pre-commit install.

Attempt to commit b.py via VS Code's source control panel. isort will abort the commit and make changes to the file, removing the line between the local and 3rd party import. Committing from the integrated terminal via git add b.py && git commit -m foo works just fine.

Expected behaviour

Committing in source control panel should work just like from the command line.

Cause

I think this might be due to VS Code invoking isort without access to the environment of installed packages. isort therefore thinks import tensorflow as tf references another local module like a.py and imports of the same type shouldn't be separated by blank lines.

@janosh janosh added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Feb 6, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Feb 6, 2020
@kimadeline
Copy link

Hi @janosh 👋 Thank you for reporting this issue.

Sadly the extension doesn't control how commit hooks are executed within the source control panel, so your best bet would be to file this issue directly against VS Code.

Thank you!

@ghost ghost removed the triage label Feb 6, 2020
@janosh
Copy link
Author

janosh commented Feb 6, 2020

Could you transfer this issue there?

@kimadeline
Copy link

No, we don't have these permissions for the microsoft/vscode repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants