Sublime Forum

SublimeLinter-pyflakes not matching pyflakes from CLI

#1

I am trying to get pyflakes working with Sublime Text 3. I have installed SublimeLinter and SublimeLinter-pyflakes via Package Control. I have installed pyflakes for python3.6 using pip. When I run pyflakes from the command line against some code I previously wrote it does not report any errors. This is what I expect. However when I run it in Sublime Text it has a problem with the first line of the following code.

self.outfile.write(f'@SP\nA=M-1\nD=M\n@SP\nM=M-1\nA=M-1\nA=M\n'
                   f'D=A-D\n@SP\nM=M-1\n@PUSH_TRUE${id}\nD;JEQ\n'
                   f'@SP\nA=M\nM=0\n@SP\nM=M+1\n@END_CHECK_EQ${id}\n'
                   f'0;JMP\n(PUSH_TRUE${id})\n@SP\nA=M\nM=-1\n'
                   f'@SP\nM=M+1\n(END_CHECK_EQ${id})\n')

This feels like it is checking against python2.7 syntax and does not reconize the f-string syntax. I removed all versions of pyflakes from my system. I then re-opened Sublime Text and it refused to activate the plugin because it could not find pyflakes in my path (as expected). I then reinstalled pyflakes and relaunched sublime text. This time subline text found pyflakes in my path and activated the plugin and reported the same error. So at very least I know its using the correct executable on my system. The same one that does not report any errors when I run it manually.

SublimeLinter: pyflakes imported <module 'pyflakes.api' from '/usr/local/lib/python3.6/site-packages/pyflakes/api.py'> 
SublimeLinter: pyflakes version: 1.6.0 
SublimeLinter: pyflakes: (>= 0.7.3) satisfied by 1.6.0 
SublimeLinter: pyflakes activated: <builtin> 
environment variables loaded using: /usr/local/bin/bash -l
SublimeLinter: pyflakes: test.py <builtin> 
SublimeLinter: pyflakes output:
test.py:169:75: invalid syntax
            self.outfile.write(f'@SP\nA=M-1\nD=M\n@SP\nM=M-1\nA=M-1\nA=M\n'

Any guidence would be appreciated. I am on macOS 10.12.6 and using SublimeText 3 Build 3143. Python 3.6.2 is installed via homebrew and /usr/local/bin/python is a symlink to /usr/local/bin/python3.

0 Likes

#2

flake8 works just fine which is odd since my understanding is it is just a wrapper around pyflakes as well as some additional linting packages. I probably will just stick with flake8 since it includes everything pyflakes includes plus more.

0 Likes

#3

I suggest opening an issue at the appropriate repo:

The root cause for this is that SublimeLinter tries to be smart and imports the pyflakes module (after adding it to sys.path), but linting tools require stdlib features to be compatible for the version they are used on because of things like new syntax. The ast module (or compile even) of Python 3.3 obviously can’t comprehend f-string syntax, since that has been added in 3.6, so it just fails parsing it.

This has caused so many problems in the past, I wonder why it’s still a thing. (I especially don’t like adding a different version’s site packages to sys.path.)

0 Likes