syntastic+pylint complain about a module's name in vim, but if I run a similar pylint command in a shell all seems OK

351 views
Skip to first unread message

Dan Stromberg

unread,
Mar 18, 2016, 6:09:23 PM3/18/16
to vim-syntastic, dstro...@cylance.com

Hi folks.

I'm using syntastic 3.7.0-99 in vim 7.4 with pylint 1.5.4 on a Linux Mint 17.3 system.

I'm attempting to shut off this warning in vim (from syntastic) :
   tests/testMOMLClassifier.py|1 col 1 warning| [invalid-name] Invalid module name "testMOMLClassifier"

I have syntastic set up to use a bash environment variable $PYLINT_ARGS, like:
   let g:syntastic_python_checkers = ['pylint']
   let g:syntastic_python_pylint_post_args = "$PYLINT_ARGS"

If I run the file through:
   pylint $PYLINT_ARGS tests/testMOMLClassifier.py
...things appear to work fine - no warning about the module name.

My intuition is telling me that it's some sort of quoting issue, but futzing with the quoting in my .bashrc hasn't produced any benefit yet.  I tried some extra backslashes, but nothing.  I also tried putting something like
   let g:syntastic_python_pylint_post_args = $(eval echo "$PYLINT_ARGS")
...in my .vimrc, but that made vim complain - sometimes that trick seems to help with bash quoting, but not this time.

My $PYLINT_ARGS setting (in my ~/.bashrc) looks like:
   export PYLINT_ARGS="--module-rgx='[a-zA-Z_][a-zA-Z0-9_]*$' --max-line-length 120 --indent-string='\t' --disable=mixed-indentation,line-too-long,missing-docstring,too-many-public-methods,too-few-public-methods,import-error,no-name-in-module,not-callable,locally-disabled,bad-continuation"
Please pay particular attention to that first argument: --module-rgx.  That's the one I'm hoping will turn off the warning.

I do have a pylint.rc - sometimes in the CWD, sometimes not.  It doesn't appear to be changing this behavior.  I also tried editing the module-rgx in pylint.rc, but that didn't help.

Thanks!

PS: Please let me know if there's any further info I can collect that might help lead to a resolution to this problem.

LCD 47

unread,
Mar 19, 2016, 4:46:42 AM3/19/16
to vim-syntastic
Passing options to pylint in an environment variable is an odd idea,
but you can make it work if you insist. This works:

export PYLINT_ARGS='--module-rgx=[a-zA-Z_][a-zA-Z0-9_]*$ --max-line-length 120 --indent-string=\t --disable=mixed-indentation,line-too-long,missing-docstring,too-many-public-methods,too-few-public-methods,import-error,no-name-in-module,not-callable,locally-disabled,bad-continuation'

This also works:

let g:syntastic_python_pylint_post_args =
\ '--module-rgx=''[a-zA-Z_][a-zA-Z0-9_]*$'' --max-line-length 120 --indent-string=''\t'' --disable=mixed-indentation,line-too-long,missing-docstring,too-many-public-methods,too-few-public-methods,import-error,no-name-in-module,not-callable,locally-disabled,bad-continuation'

And this works too:

let g:syntastic_python_pylint_post_args =
\ [ '--module-rgx='[a-zA-Z_][a-zA-Z0-9_]*$',
\ '--max-line-length', '120',
\ '--indent-string=\t',
\ '--disable=mixed-indentation,line-too-long,missing-docstring,' .
\ 'too-many-public-methods,too-few-public-methods,import-error,' .
\ 'no-name-in-module,not-callable,locally-disabled,bad-continuation' ]

The reason why these work and your attempts don't, has to do with
the way Vim's system() is implemented. Look at Vim's sources if you're
curious. Contrary to the popular belief it isn't really something you
could easily infer from the manual.

Back to your question, the easier way to handle all this is to put
all options in a configuration file. According to pylint's manual,
pylint will use the first file it can find out of:

* a file pointed to by the envirionment variable PYLINTRC
* ~/.pylintrc
* /etc/pylintrc

It won't look for a pylint.rc, either in the current directory, or
elsewhere, unless you explicitly use --rcfile=/path/to/pylint.rc .

/lcd

Dan Stromberg

unread,
Mar 21, 2016, 3:03:15 PM3/21/16
to vim-syntastic

On Saturday, March 19, 2016 at 1:46:42 AM UTC-7, LCD 47 wrote:
On 18 March 2016, Dan Stromberg <drsa...@gmail.com> wrote:


    Passing options to pylint in an environment variable is an odd idea,
but you can make it work if you insist.  This works:

export PYLINT_ARGS='--module-rgx=[a-zA-Z_][a-zA-Z0-9_]*$ --max-line-length 120 --indent-string=\t --disable=mixed-indentation,line-too-long,missing-docstring,too-many-public-methods,too-few-public-methods,import-error,no-name-in-module,not-callable,locally-disabled,bad-continuation'
This fixed it.

Thanks!

Reply all
Reply to author
Forward
0 new messages