black: vim plugin way of installing black is broken
Describe the bug
The way the vim plugin install black is broken because:
- it does not guarantee the installed
blackwill actually be used as it is added at the end ofsys.pathso any other version on the system will be used instead - it install the latest version of black registered on pypi which can be incompatible with the vim plugin itself, in particular when following the installation instructions as
Plugwill install from master
To Reproduce Steps to reproduce the behavior:
- Add
Plug 'psf/black'to your vimrc - Run
vim -c PlugInstall - Run
vim foo.py -c Black - See error:
"foo.py" [New File]
Error detected while processing command line:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 97, in Black
File "<string>", line 133, in get_configs
AttributeError: module 'black' has no attribute 'find_pyproject_toml'
Expected behavior
No error and vim ready to edit the file.
Environment (please complete the following information):
- Version: master
- OS and Python version: Linux/Python 3.7.5
Additional context
Somewhat related issue about the forced installation of black by the vim plugin: #1269
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 30
- Comments: 22 (5 by maintainers)
Links to this issue
Commits related to this issue
- fix: Fixing the documentation of how to install the vim plugin Solves the installation problem that currently exist because the current master branch is not stable. See psf/black#1304 for more inform... — committed to shaoran/black by shaoran 4 years ago
- Fixing the documentation of how to install the vim plugin (#1318) * fix: Fixing the documentation of how to install the vim plugin Solves the installation problem that currently exist because the... — committed to psf/black by shaoran 4 years ago
- Pin black to 19.10b0 See https://github.com/psf/black/issues/1304 — committed to zsiciarz/dotfiles by zsiciarz 4 years ago
Using Plug:
Thanks to @bkjohnson for showing how to pin vim-black to the installed release from pypi using vim-plug:
For anyone interested, until this bug is fixed using commit ce14fa8b497bae2b50ec48b3bd7022573a59cdb1 works fine, as the commit 8fef74cf527d7fa5f2da78fafc61152c8766d0ad is the one which introduces ‘find_pyproject_toml’ function.
For example using dein
I have to provide a
branchto make it work.I think this can now be closed (cf. #1318).
Thanks @PanagiotisS! I had a couple issues
:echo has('python3')would always net 0Cleaning out the plugin dir and resintalling as well as installing
pynvimseemed to get it to work!@richtong check out my fork https://github.com/EgZvor/vim-black it uses the executable available in the system and supports ranges.
Oh, is #1318 ALSO the fix for 1379? Indeed, indeed it is!