The following code shows invalid syntax. I assume syntastic is looking at Python2 for syntax-checking. I need it to look at Python3 instead.

def x():
  x = 42
  def y():
    nonlocal x
    x = 8
    return x
  return y

print( x()() )

nonlocal is the method of telling Python3 that you do not want to shadow x. It's a great and powerful feature that let's me quick and easily obscure code, and one of the many benefits of lacking my, let, dim, and the like on variable declaration.


1 Answer 1


Using Ubuntu, I couldn't figure out what was calling python or to change the default environment for all instances of syntastic. That would have been desirable.

Instead what I did was install flake8,

pip3 install flake8

Then you can easily configure this to work by adding the following line to your ~/.vimrc

let g:syntastic_python_checkers=['flake8']

Beware though this has a lot of stuff that isn't just syntax checking, including a style-guide. I'm not sure why this just be as changing the default in a vim conf, but this seems to work.

  • 2
    ... which doesn't work, because there is no syntastic checker named python3. Believe it or not, the solution is described in the FAQ.
    – lcd047
    Sep 25, 2018 at 18:10
  • @lcd047 good catch, it wasn't working. the error went away but it wasn't catching subsequent errors I moved to use flake8 which is certainly working (and loud af) Sep 25, 2018 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.