Skip to content

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

Closed

Description

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.

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Feb 6, 2020
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Feb 6, 2020
  3. kimadeline commented on Feb 6, 2020

    @kimadeline

    Hi Janosh Riebesell (@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!

  4. ghost removed on Feb 6, 2020
  5. janosh commented on Feb 6, 2020

    @janosh
    Author

    Could you transfer this issue there?

  6. kimadeline commented on Feb 6, 2020

    @kimadeline

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

  7. locked as resolved and limited conversation to collaborators on Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions