-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 aInstall 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.