Syntastic: feature request: syntax check support for Python 3

Created on 30 Jun 2012  路  10Comments  路  Source: vim-syntastic/syntastic

Just like the title write, I hope Syntastic support Python 3.

obsolete solution

Most helpful comment

Note you should actually be setting g:syntastic_python_python_exec, NOT g:syntastic_python_python_exe (as per here):

let g:syntastic_python_python_exec = 'python3'

All 10 comments

Doesn't it already have support ? It uses a couple different python checkers, I would think at least one supports Python 3.

I find that syntastic shows an error with the print function (python3) but is happy with the old syntax.
Do I have to do something to tell syntastic that I am working with python3?

@phanimahesh: You tell us. :) There are two potential problems with the python checker:

  1. you might get the (in)famous E40 error when checking a file with unusual characters in the name;
  2. some errors are not recognized.
    Please post a bug report if you run into any of them.

@lcd047 I have a different problem.

  • The file name has no unusual characters and I do not enounter E40.
  • Something that is _not_ an error is being detected as one.
# This is detected as a syntax error, but is valid python3
print('Just Testing',file=sys.stderr)

So my question is:

  • Does syntastic really support python3? (Answered yes before this issue was closed.)
  • How does syntastic know if I'm working with python2 or python3? ( What is the detection algorithm, if there is one?)
  • Can I override it? ( Syntastic detects python2 but I want to treat my file as python3, or vice-versa)

Syntastic doesn't care about python versions, it just calls a program named python, and tries to parse whatever errors that program produces. You can, of course, override it:

let g:syntastic_python_python_exe = 'python3'

Thanks. That solved my issues. :)

Note you should actually be setting g:syntastic_python_python_exec, NOT g:syntastic_python_python_exe (as per here):

let g:syntastic_python_python_exec = 'python3'

Using g:syntastic_python_python_exe was appropriate at the time, for a brief while; it no longer is for recent versions of syntastic. Which is why you should read the manual, or at least the FAQ before searching the archives: old advice might be outdated.

@lcd047 Indeed. Unfortunately this is the first result on Google when searching for "python3 syntastic", so it's probably worthwhile making the point explicitly.

There also seems to be a widespread confusion about it on StackOverflow. The exe thing is rarely useful outside syntastic code itself, it should probably be renamed to something else. Sadly doing so would break a few third-party checkers, and checking syntastic version is also awkward, for similar historic reasons.

Was this page helpful?
0 / 5 - 0 ratings