black
black copied to clipboard
Fix handling of mismatched Python version in virtualenv
Description
This fixes #2547 for the (default) case when g:black_use_virtualenv = 1.
The fix for g:black_use_virtualenv = 0 is a superset of these changes but is more invasive so I'll create a separate branch for it.
To trigger the bug on Linux:
- make sure you don't have
blackinstalled as a system package:apt purge black - launch vim built with Python 3.X
- run
:BlackVersion, let it finish creating the virtualenv, close vim - launch vim built with Python 3.Y
- run
:BlackVersion, you should see an error:ModuleNotFoundError: No module named 'black'
I usually encounter this issue when I upgrade to a new Kubuntu release which has a newer Vim built against a newer Python, since I keep the same user data so the old virtualenv created for black is still there.
Checklist - did you ...
- [x] Add an entry in
CHANGES.mdif necessary? - [x] Add / update tests if necessary?
- [x] Add new / update outdated documentation?