Black: Unexpected kwarg line_length when using Vim plugin

Created on 19 Mar 2019  路  13Comments  路  Source: psf/black

Operating system: macOS 10.14.3
Python version: 3.7.2
Black version: 19.3b0
Does also happen on master: yes

When using the provided Vim (8.1) plugin, the following appears when trying to run :Black:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 65, in Black
TypeError: __call__() got an unexpected keyword argument 'line_length'

It might be related to #766, but I haven't yet investigated thoroughly. I'll try doing so as soon as I find some time, which will hopefully be later today.

Most helpful comment

@JPFrancoia @JPFrancoia One thing I did _around_ that time (I can't remember exactly, sorry) was :BlackUpgrade from inside Vim.

All 13 comments

Very odd, but now鈥攎inutes later and with no changes to my system that I'm aware of鈥攅verything works fine. 馃槓

I'm experiencing this too actually, if you can figure out what you did to fix it I'd greatly appreciate it!

Same here, can't figure out what the problem is.

I got the problem, in my case it was due to mismatch version between the vim plugin (19.3b0) and the version of the lib in my virtualenv (18.9b0).

Solution I use is tu update my virtualenv black package.

I thought that might have been it, but I really tried to get pipenv to update it. Guess it must not have been cooperating, thanks for the tip!

@JPFrancoia @JPFrancoia One thing I did _around_ that time (I can't remember exactly, sorry) was :BlackUpgrade from inside Vim.

ah yeah ,the mismatch might have been the problem. I pinned the version of Black in my pipfile and forgot about it. I ended up "solving" the problem by git checkout to the latest stable commit in the plugin directory. Probably not the cleanest way to do it...

Thanks for your help guys.

I have the same problem. When typing black --version in the terminal I get: black, version 19.3b0. But when opening Neovim and running :BlackVersion I get: Black, version 18.9b0 on Python 3.7.2 (default, Feb 12 2019, 08:15:36) [Clang 10.0.0 (clang-1000.11.45.5)]. :BlackUpgrade does not help. Shouldn't those be the same version?

@Joellidin Are you using the latest version of the plugin itself?

@nkantar Yes I tested to reinstall the plugin but got the same problem. Putting let g:black_virtualenv = '/usr/local/bin/' in my .vimrc fixed it though. But how would one use it then with certain virtual environments?

Thanks @Joellidin , your let g:black_virtualenv .... trick did it for me (in my case I was pointing to virtualenv, created by pipx).

Regarding usage in certain virtual environments: I do not think, there is any problem. If I understand black well, it does not load your code in your virtualenv, it only processes the text regardless of currently active python environment. For this reason I expect globally installed black working well within any virtualenv.

:BlackUpgrade worked fine for me and updated from 18.9b0 > 19.3b0. Had the same issue.

:BlackUpgrade worked for me, but only after I closed and re-opened vim. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dimaqq picture dimaqq  路  3Comments

brettcannon picture brettcannon  路  3Comments

layoaster picture layoaster  路  3Comments

bhearsum picture bhearsum  路  3Comments

feluxe picture feluxe  路  3Comments