Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9027ca6

Browse files
joshbodeambv
authored andcommitted
Change how venv path is modified in vim plugin (psf#804)
- Check if black venv path is not already in `sys.path` - Append (not insert) path so that black doesn't incorrectly import backports (e.g. `typing`) Avoids this error if `typing` is present in venv: ``` Traceback (most recent call last): File "<string>", line 56, in <module> File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/black.py", line 19, in <module> from typing import ( File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/typing.py", line 1356, in <module> class Callable(extra=collections_abc.Callable, metaclass=CallableMeta): File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/typing.py", line 1004, in __new__ self._abc_registry = extra._abc_registry AttributeError: type object 'Callable' has no attribute '_abc_registry' ```
1 parent b73ec93 commit 9027ca6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

plugin/black.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def _initialize_black_env(upgrade=False):
9494
print('DONE! You are all set, thanks for waiting ✨ 🍰 ✨')
9595
if first_install:
9696
print('Pro-tip: to upgrade Black in the future, use the :BlackUpgrade command and restart Vim.\n')
97-
if sys.path[0] != virtualenv_site_packages:
98-
sys.path.insert(0, virtualenv_site_packages)
97+
if virtualenv_site_packages not in sys.path:
98+
sys.path.append(virtualenv_site_packages)
9999
return True
100100

101101
if _initialize_black_env():

0 commit comments

Comments
 (0)