JulianEberius / SublimePythonIDE

ST3 only: A rewrite of SublimeRope for ST3, uses the Rope library to add python completions and refactoring to ST3
GNU General Public License v2.0
267 stars 38 forks source link

Updated pyflakes to 0.7.3 #48

Closed miohtama closed 10 years ago

miohtama commented 10 years ago

This upgrades internal pyflakes to version 0.7.3.

It fixes issue #46 (compatibility with SublimeLinter-flake8) where both the Sublime Text packages try to access the shared version of this library.

I manually tested functionality (Get documentation, Go to definition) and nothing seemed to break.

JulianEberius commented 10 years ago

The functions you checked work, but the linting itself does not, as some stuff in PyFlakes has changed... "lineno" (see traceback below) is now an int, was some structured type before. I fiddled around with it for a bit, but I did not quickly find a solution ( the linting code in SublimePythonIDE was not done by me). I will look into this later if there is more time.

Traceback (most recent call last):
  File "server/server.py", line 302, in check_syntax
    codes = do_linting(lint_settings, code, encoding, filename)
  File "/Users/ebi/Library/Application Support/Sublime Text 3/Packages/SublimePythonIDE/server/linter.py", line 181, in do_linting
    errors.extend(pyflakes_check(code, encoding, filename, pyflakes_ignore))
  File "/Users/ebi/Library/Application Support/Sublime Text 3/Packages/SublimePythonIDE/server/linter.py", line 95, in pyflakes_check
    error = OffsetError(filename, lineno, msg, offset)
  File "/Users/ebi/Library/Application Support/Sublime Text 3/Packages/SublimePythonIDE/server/linter.py", line 55, in __init__
    filename, loc, 'E', '[E] %r', (text,), offset=offset + 1, text=text
  File "/Users/ebi/Library/Application Support/Sublime Text 3/Packages/SublimePythonIDE/server/linter.py", line 22, in __init__
    super(PythonLintError, self).__init__(filename, loc)
  File "/Users/ebi/Library/Application Support/Sublime Text 3/Packages/SublimePythonIDE/server/../lib/pyflakes/messages.py", line 12, in __init__
    self.lineno = loc.lineno
AttributeError: 'int' object has no attribute 'lineno'
miohtama commented 10 years ago

Ok. I'll try to repeat the error!

miohtama commented 10 years ago

I had been unfortunate (fortunate enough?) not to hit this error path when testing SublimePythonIDE.

Apparently AST / pyflakes has changed the format how error is reported; it is not anymore just line number, but an object with lineno and optional col_offset attribute. I changed the code so that we'll spoof this object in the format Pyflakes expects.

At least now I cannot repeat the issue anymore with simple indentation error like this one below:

#!/usr/bin/env python
import os
 import sys

The fix in the commit.

xiaochuanyu commented 10 years ago

@JulianEberius , any updates on this? 0.7.x of pyflakes fixes some annoying bugs like not recognizing certain list comprehensions correctly (https://bugs.launchpad.net/pyflakes/+bug/1112067).

JulianEberius commented 10 years ago

Thanks! Seems to work, I've merged it into master.

miohtama commented 10 years ago

Thanks! I released a blog post, mentioning SublimePythonIDE: http://opensourcehacker.com/2014/03/10/sublime-text-3-for-python-javascript-and-web-developers/