How can I set the Python max allowed line length to 120 in Syntastic for Vim?
Asked Answered
M

4

32

I'm using python-mode for Vim, I prefer for there to be 120 character lines rather than the stark 80 as defined in the PEP8 standard.

In python-mode, this is easy. I just add the following to my ~/.vimrc:

" Pylint configuration file
let g:pymode_lint_config = '$HOME/.pylint.rc'
let g:pymode_options_max_line_length=120

This works great, but then, I also wanted to use the superb Syntastic plugin for checking syntax of various other kinds (Chef recipes for foodcritic, for example.)

Unfortunately, Syntastic also does Python linting, and as such it has now started complaining about my 120 character lines. Is there something similar I can do to it as well to make it stop complaining about my slightly longer lines?

Malocclusion answered 23/1, 2015 at 20:54 Comment(1)
don't you have to specify which syntax checkers to use? I have let g:syntastic_python_checkers=['pylint'] in my vimrc. What is your g:syntastic_python_checkers set to?Accidence
R
17

You can pass additional arguments to each linter. For pylint, you can use:

let g:syntastic_python_pylint_post_args="--max-line-length=120"
Rafter answered 23/1, 2015 at 21:16 Comment(0)
M
57

This is now configured globally in ~/.config/flake8 in linux and ~/.flake in windows. The file can look like this.

[flake8]
max-line-length = 120

Have a look at their documentation for per project settings: http://flake8.readthedocs.io/en/latest/user/configuration.html#project-configuration

Misgive answered 9/6, 2016 at 8:57 Comment(0)
R
17

You can pass additional arguments to each linter. For pylint, you can use:

let g:syntastic_python_pylint_post_args="--max-line-length=120"
Rafter answered 23/1, 2015 at 21:16 Comment(0)
P
4

I would just recommend you disable the length checking by adding this line to your .vimrc dot file:

let g:pymode_lint_ignore = "E501,W"
Protolanguage answered 21/9, 2017 at 3:59 Comment(0)
P
-2

There is a file named - defaults.py inside your virtual environment folder - ......./lib/python3.6/site-packages/flake8

You can change the value of max-line-length in that file.

Phyllode answered 9/5, 2019 at 6:11 Comment(1)
I know this is an older post, but since it was the first result I found via google for "increasing line length for pylint", I wanted to say that it's generally a really bad idea to edit installed python libraries.Partly

© 2022 - 2024 — McMap. All rights reserved.