sublimelinter / sublimelinter-flake8 Goto Github PK
View Code? Open in Web Editor NEWSublimeLinter plugin for python, using flake8.
License: MIT License
SublimeLinter plugin for python, using flake8.
License: MIT License
Hey!
I've just bumped up to Python3 and have found that I can no longer pass extra args to flake8 via the SublimeLinter plugin.
I'm currently defining args in my SublimeLinter prefs as so:
"args": [
"--radon-max-cc",
"6"
]
Looking at the logs in debug mode - Python2 shows something like this:
SublimeLinter: flake8: list_.py ['/python2.7/bin/python', '/python2.7/bin/flake8', '--radon-max-cc', '1', '--max-complexity=-1', '--jobs=1', '--max-line-length=100', '--ignore=P101,P102,P103', '-']
However, in Python3, it looks to be operating in a totally different manner:
SublimeLinter: flake8: list_.py <builtin>
SublimeLinter: flake8 options: {'max_line_length': 100, 'jobs': '1', 'reporter': <class 'SublimeLinter-flake8-master.linter.Flake8.get_report.<locals>.Report'>, 'max_complexity': -1, 'ignore': ['P101', 'P102', 'P103']}
I'm struggling to see how I should be passing through the custom arguments!
Any help would be much appreciated.
Cheers,
Ian
Hi, and thanks for reading.
So, I just upgraded to Sublime Text 3 and installed SublimeLinter via Package Control.
I just noticed that now, SublimeLinter takes into account E501, but that disturbs me and I would like to disable it (disable the warning).
I installed pip, pep8 and SublimeLinter-pep8 too
Here's my SublimeLinter.sublime-settings :
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {},
"mark_style": "outline",
"no_column_highlights_line": false,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": []
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"javascript (babel)": "javascript",
"magicpython": "python",
"php": "html",
"python django": "python",
"pythonimproved": "python"
},
"warning_color": "DDB700",
"wrap_find": true
}
}
What should I add to disable E501 ? I tried everything I could find on the Web...
PS : Sorry for my bad english
This line should be ignored in checks, but this disable all checks for the whole file, which is wrong.
import pdb;pdb.set_trace() # flake8: noqa
Flake8 linting suddenly stopped working for me :(
I'm using python 2.7.6, getting the following SystemError:
reloading plugin SublimeLinter-flake8.linter
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 71, in reload_plugin
m = imp.reload(m)
File "X/imp.py", line 252, in reload
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "linter in /Users/USER/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 17, in <module>
File "/Users/USER/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 124, in __init__
cls.reinitialize()
File "/Users/USER/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/python_linter.py", line 98, in reinitialize
cls.initialize()
File "linter in /Users/USE/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 73, in initialize
SystemError: super(): empty __class__ cell
flake8 settings:
"flake8": {
"@disable": false,
"@python": 2,
"args": [],
"builtins": "",
"excludes": [],
"ignore": "",
"max-complexity": -1,
"max-line-length": 100,
"select": ""
}
I just installed the latest version this package and here's the error i have:
flake8: error: no such option: --max-complexity
My env:
Is there any setting i can override?
Reports that the line should end with a period which would screw up the syntax of the shebang line. Probably not optimal advice.
The latest update breaks sublimelinter-flake8. To confirm the update is the problem I reverted back to the v2.1.0 where everything works fine.
SublimeLinter: find_python(version=None, script='flake8', module=None)
SublimeLinter: find_python: default python = /usr/bin/python
SublimeLinter: find_python: available version = {'minor': 7, 'major': 2}
SublimeLinter: find_python: 'flake8' path = /usr/bin/flake8
SublimeLinter: find_python: <= ('/usr/bin/python', '/usr/bin/flake8', 2, 7)
SublimeLinter: flake8 version query: /usr/bin/python /usr/bin/flake8 --version
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
File "/usr/bin/flake8", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3019, in <module>
@_call_aside
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3003, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 655, in _build_master
ws.require(__requires__)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 963, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 849, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'flake8==3.2.1' distribution was not found and is required by the application
Here's is the output from flake8
mandeep@debian:~$ which flake8
/usr/bin/flake8
mandeep@debian:~$ /usr/bin/flake8 --version
3.2.1 (mccabe: 0.5.3, pycodestyle: 2.2.0, pyflakes: 1.3.0) CPython 3.5.3 on Linux
I followed the instructions in the README exactly and have ran into this issue after installing:
I have added the @python
directive to my Sublime settings as well as the SublimeLinter settings.
SublimeLinter: debug mode: on
SublimeLinter: temp directory: /var/folders/f9/3k550dp5689ggt9lj9q8nmbr0000gn/T/SublimeLinter3-lihorne
SublimeLinter: find_python(version='3', script=None, module=None)
SublimeLinter: find_python: requested version = {'major': 3, 'minor': None}
SublimeLinter: find_posix_python: python3 => /usr/local/bin/python3
SublimeLinter: find_python: system python = /usr/local/bin/python3
SublimeLinter: find_python: available version = {'major': 3, 'minor': 5}
SublimeLinter: find_python: <= ('/usr/local/bin/python3', None, 3, 5)
SublimeLinter: sys.path for /usr/local/bin/python3:
/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python35.zip
/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5
/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin
/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload
/usr/local/lib/python3.5/site-packages
SublimeLinter: WARNING: import of flake8.engine module in flake8 failed, linter will not work with python 3 code
I was a happy SublimeLinter-flake8 user, once..
Some days ago it stopped working (don't know when exactly), fiddling around I discovered that the plugin tries to launch flake8
inside python2
instead of python3
.
If I start up Sublime (with Sublimelinter "debug": true
) I have the following output in the console:
startup, version: 3114 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/spky/Library/Application Support/Sublime Text 3/Packages
state path: /Users/spky/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/spky/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["CSS", "Vintage"]
pre session restore time: 0.421869
loading dictionary Packages/Language - English/en_US.dic
startup time: 0.641907
first paint time: 0.65541
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin Rust.plugin
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.02-bz2
reloading plugin CSS3.css3_completions
reloading plugin CSS3.rgb_to_hex
reloading plugin CSS3.validator
reloading plugin EditorConfig.EditorConfig
reloading plugin GitGutter.git_gutter
reloading plugin GitGutter.git_gutter_change
reloading plugin GitGutter.git_gutter_compare
reloading plugin GitGutter.git_gutter_events
reloading plugin GitGutter.git_gutter_handler
reloading plugin GitGutter.git_helper
reloading plugin GitGutter.view_collection
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
reloading plugin SublimeLinter-contrib-rustc.linter
SublimeLinter: rust linter loaded
reloading plugin SublimeLinter-flake8.linter
SublimeLinter: flake8 linter loaded
reloading plugin SublimeLinter-jsl.linter
SublimeLinter: jsl linter loaded
reloading plugin SublimeLinter-json.linter
SublimeLinter: json linter loaded
reloading plugin SublimeLinter-luacheck.linter
SublimeLinter: luacheck linter loaded
reloading plugin SublimeLinter-shellcheck.linter
SublimeLinter: shellcheck linter loaded
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.sublimelinter
plugins loaded
SublimeLinter: debug mode: on
SublimeLinter: temp directory: /var/folders/46/ly858_nd3f19frcj_zghlnlc0000gn/T/SublimeLinter3-spky
SublimeLinter: find_python(version='3', script=None, module=None)
SublimeLinter: find_python: requested version = {'major': 3, 'minor': None}
SublimeLinter: user shell: /usr/local/bin/zsh
SublimeLinter: computed PATH using /usr/local/bin/zsh:
/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/X11/bin
/Users/spky/bin
/usr/local/MacGPG2/bin
/Library/TeX/texbin
SublimeLinter: find_posix_python: python3 => /usr/local/bin/python3
SublimeLinter: find_python: system python = /usr/local/bin/python3
SublimeLinter: find_python: available version = {'major': 3, 'minor': 5}
SublimeLinter: find_python: <= ('/usr/local/bin/python3', None, 3, 5)
SublimeLinter: sys.path for /usr/local/bin/python3:
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python35.zip
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload
/usr/local/lib/python3.5/site-packages
SublimeLinter: json activated: <builtin>
Package Control: Skipping automatic upgrade, last run at 2016-06-14 19:00:45, next run at 2016-06-14 20:00:45 or after
Yay, looks great, the SHELL
is discovered correctly, as well as all system PATH
s..
The moment when I type into some Python file, the console outputs this:
SublimeLinter: find_python(version=None, script='flake8', module=None)
SublimeLinter: find_python: default python = /usr/local/bin/python
SublimeLinter: find_python: available version = {'major': 2, 'minor': 7}
SublimeLinter: find_python: 'flake8' path = /usr/local/bin/flake8
SublimeLinter: find_python: <= ('/usr/local/bin/python', '/usr/local/bin/flake8', 2, 7)
SublimeLinter: flake8 version query: /usr/local/bin/python /usr/local/bin/flake8 --version
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
File "/usr/local/bin/flake8", line 7, in <module>
from flake8.main import main
ImportError: No module named flake8.main
I have flake8
installed (via pip3 install -U flake8
), it also works correctly (if called manually from the commandline).
Steps I've already tried:
"@python": 3.5
metavar inside the SublimeLinter config, tried any level
SublimeLinter-flake8
flake8
(as well as pep8
, pyflakes
& mccabe
)
SublimeLinter
Sublime
, importing my old settings afterwards.
What am I missing, what am I doing wrong?
Please help me become a happy user of SublimeLinter-flake8 again.
When I flake8 the file from the command line everything passes, but I get invalid syntax from the plugin.
I'm using pyenv, but the shims seem to be loading correctly below, since it pulls the path from the global python version.
$ pyenv global
3.5.0
Output from editor open to file lint (conftest.py)
DPI scale: 1
startup, version: 3083 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
working dir: /
packages path: /home/numberoverzero/.config/sublime-text-3/Packages
state path: /home/numberoverzero/.config/sublime-text-3/Local
zip path: /opt/sublime_text/Packages
zip path: /home/numberoverzero/.config/sublime-text-3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.10723
startup time: 0.205469
first paint time: 0.255404
<SNIP> reloading plugin spam </SNIP>
reloading plugin SublimeLinter-flake8.linter
SublimeLinter: flake8 linter loaded
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.sublimelinter
plugins loaded
SublimeLinter: debug mode: on
SublimeLinter: temp directory: /tmp/SublimeLinter3-numberoverzero
SublimeLinter: find_python(version='3', script=None, module=None)
SublimeLinter: find_python: requested version = {'minor': None, 'major': 3}
SublimeLinter: user shell: /bin/bash
SublimeLinter: computed PATH using /bin/bash:
/home/numberoverzero/.pyenv/shims
/home/numberoverzero/.pyenv/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/usr/local/bin
/home/numberoverzero/bin
~/npm/bin
/home/numberoverzero/.rvm/bin
SublimeLinter: find_posix_python: python3 => /home/numberoverzero/.pyenv/shims/python3
SublimeLinter: find_python: system python = /home/numberoverzero/.pyenv/shims/python3
SublimeLinter: find_python: available version = {'minor': 5, 'major': 3}
SublimeLinter: find_python: <= ('/home/numberoverzero/.pyenv/shims/python3', None, 3, 5)
SublimeLinter: sys.path for /home/numberoverzero/.pyenv/shims/python3:
/home/numberoverzero/ws/bloop
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/site-packages/arrow-0.7.0-py3.5.egg
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/site-packages/jmespath-0.9.0-py3.5.egg
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/site-packages/python_dateutil-2.4.2-py3.5.egg
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/site-packages/six-1.10.0-py3.5.egg
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python35.zip
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/plat-linux
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/lib-dynload
/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/site-packages
SublimeLinter: flake8 imported <module 'flake8.engine' from '/home/numberoverzero/.pyenv/versions/3.5.0/lib/python3.5/site-packages/flake8/engine.py'>
Package Control: Skipping automatic upgrade, last run at 2016-01-12 19:34:04, next run at 2016-01-12 20:34:04 or after
SublimeLinter: flake8 version: 2.5.1
SublimeLinter: flake8: (>= 2.2.2) satisfied by 2.5.1
SublimeLinter: flake8 activated: <builtin>
SublimeLinter: chdir not set or invalid, using /home/numberoverzero/ws/bottom/tests
SublimeLinter: flake8: conftest.py <builtin>
SublimeLinter: flake8 options: {'reporter': <class 'SublimeLinter-flake8.linter.Flake8.get_report.<locals>.Report'>, 'jobs': '1', 'max_complexity': -1}
SublimeLinter: flake8 output:
conftest.py:22:14: E901 SyntaxError: invalid syntax
Cannot configure the last version (for sublimelinter 3) to work with shebang.
I'm on Windows and before (with my PR):
When my script start with #!python3
, flake8 from python3 is used.
When no shebang or start with #!python2
, flake8 from python2 is used.
It seems to me that shebang is now totally ignored, probably because the @pyhon
was removed from cmd = ('flake8@python', '*', '-')
Py2.7 / ST3 / SL / SL-flake8
Everything seems to be working fine, yet I get no input from flake8.
Toggle flake8 is enabled.
Trying to get my mind around it, but when there are no errors it's just mind blowing.
SublimeLinter: debug mode: off
SublimeLinter: WARNING: import of flake8.engine module in flake8 failed, linter will not work with python 3 code
SublimeLinter: flake8 activated: C:\Python27\Scripts\flake8.exe
found 4 files for base name Main.sublime-menu
Emmet: No need to update PyV8
Package Control: Skipping automatic upgrade, last run at 2015-03-03 01:03:57, next run at 2015-03-03 02:03:57 or after
From http://flake8.pycqa.org/en/latest/user/error-codes.html
We also report one extra error: E999. We report E999 when we fail to compile a file into an Abstract Syntax Tree for the plugins that require it.
I have the flake8 linter installed and working, but when I load the package I get these messages:
SublimeLinter: debug mode: off
SublimeLinter: WARNING: import of flake8.engine module in flake8 failed, linter will not work with python 3 code
Writing file /Users/Shadow/Library/Application Support/Sublime Text 3/Packages/User/SublimeLinter.sublime-settings with encoding UTF-8 (atomic)
reloading Packages/User/SublimeLinter.sublime-settings
found 35 files for base name Main.sublime-menu
Package Control: Skipping automatic upgrade, last run at 2014-11-18 10:23:54, next run at 2014-11-18 11:23:54 or after
Registering handler with address ('localhost', 53801)
SublimeLinter: WARNING: no flake8 version could be extracted from:
File "/Users/Shadow/.pyenv/shims/flake8", line 3
[ -n "$PYENV_DEBUG" ] && set -x
^
SyntaxError: invalid syntax
When running the command flake8 --verions
I get the following results 2.2.5 (pep8: 1.5.7, pyflakes: 0.8.1, mccabe: 0.2.1) CPython 2.7.8 on Darwin
Ever since a recent-ish update to SublimeLinter-flake8, there's an intrusive inline popup that shows up while I am typing. It's especially bad because it overrides SublimeText's auto-complete box. I can't find a way to deactivate it.
SublimeLinter already has an option to lint on save and to show a popup when a lint happens. Why is this functionality replicated in SublimeLinter-flake8?
SubmlimeLinter-flake8 throws an error "missing docstring in public module" on all the files. I don't see this error when i run flake8 on the terminal.
flake8 --version 3.2.1 (pyflakes: 1.3.0, flake8-docstrings: 1.0.2, pydocstyle: 1.1.1, mccabe: 0.5.2, pycodestyle: 2.2.0) CPython 2.7.9 on Darwin
pep8 --version 1.5.7
First of all thank you for SublimeLinter and thank you for extending it with Flake8, as it makes coding Python in Sublime so much more enjoyable!
I believe I have a problem with my paths settings of SublimeLinter-flake8.
This expresses itself in:
Both sublime-anaconda and python itself do not express any problem with the respective python files.
(Anaconda understands the Python 3.6 syntax and autocompletes with content from the extra folder. Python itself can execute the scripts without any error.)
Tell me what information you require to understand this problem and I will provide it.
Thanks.
Below are two links to threads on Sublime Forum and stackoverflow respectively where I discuss this issue.
They also contain an excerpt from my sublime-linter's .sublime-setttings file.
If we pass --format default
we will (hopefully) override any formatting a user may have set in its config file. We need the default style, otherwise our regex can't match.
The README.md reads:
@python A meta setting that indicates the python version of your source files. Use this inline or at the global level, not within the linter’s settings.
Why should I not use it within the linter's settings (works fine for me BTW)? And how would I set it at global level instead?
Please add an builtins
option (like for ignore
) to the linter to suppress warnings of known but not defined globals.
I get a different output from running the flake8 command on the terminal compared to what sublimelinter tells me. For example:
$ flake8 public
public/admin.py:3:6: H304 No relative imports. 'from .models import PublicPicture' is a relative import
I've tried to specifically include 'H' errors in the settings, but it still doesn't show up:
"settings":
{
"anaconda_linting": false,
"SublimeLinter": {
"debug": true,
"linters": {
"flake8": {
"@disable": false,
"args": [],
"builtins": "",
"excludes": [],
"ignore": "",
"select": "H304"
}
},
"paths": {
"linux": [],
"osx": [
"/Users/dries/src/csm/_csm/bin"
],
"windows": []
},
"python_paths": {
"linux": [],
"osx": [
"/Users/dries/src/csm/_csm/bin"
],
"windows": []
},
},
"python_interpreter": "/Users/dries/src/csm/_csm/bin/python"
}
Is this plugin not expected to show warnings/errors displayed by flake8 plugins?
The plugins I'm using for flake8 are these:
$ flake8 --version
2.5.5 (pep8: 1.5.7, mccabe: 0.2.1, hacking.core: 0.0.1, ProxyChecker: 0.0.1, pyflakes: 0.8.1) CPython 2.7.12 on Darwin
The specific plugin that warns about relative imports is 'hacking.core'. Or is there maybe a better way to enforce this coding style: http://docs.openstack.org/developer/hacking/
I am just doing fresh Sublime Text 3 + SublimeLinter installation. I am getting the following:
reloading plugin SublimeLinter-flake8.linter
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "linter in /Users/mikko/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 17, in <module>
File "/Users/mikko/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 124, in __init__
cls.reinitialize()
File "/Users/mikko/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/python_linter.py", line 98, in reinitialize
cls.initialize()
File "linter in /Users/mikko/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 53, in initialize
SystemError: super(): empty __class__ cell
Any idea what could cause this or how to start to diagnose the problem?
The whole process just hangs and nothing happens.
(2.2.2) does work
Setting show-code
option doesn't work, breaking also the whole linting.
Here is the error from console:
SublimeLinter: flake8: vminfo_quick.py ['/usr/bin/python2.7', '/usr/local/bin/flake8', '--ignore=F403,E111,E113', '--max-line-length=100', '--jobs=1', '--max-complexity=-1', '--show-code=True', '-']
SublimeLinter: flake8 output:
Usage: flake8 [options] input ...
flake8: error: no such option: --show-code
When ST "reloads" plugins at startup if a plugin is already loaded it will unload it then reload it. linter.py
imports util.py
so it gets loaded, when ST then tries to load util.py it sees that it's already loaded so it unloads it and then reloads. This is extra overhead and can cause side-effect hard-to-debug issues.
ST only autoloads modules in the root package so the fix is to move util.py into a sub directory or move the code into linter.py
.
I don't know when I'd get a chance to submit a PR or which fix you'd prefer. Looking at the code in util I'd just push the code into linter.py
, it's not a huge amount of code.
Have you seen this issue?
SublimeLinter: debug mode: off
SublimeLinter: WARNING: import of flake8.engine module in flake8 failed, linter will not work with python 3 code
SublimeLinter: WARNING: flake8 deactivated, cannot locate 'flake8@python'
I install flake8 in a virtualenv using pipsi. This sets up a bin directory in my path to call python scripts but keeping them isolated in virtualenvs.
It works fine when flake8 is run normally:
kstone@kstone-mbp ~> which flake8
$HOME/.local/bin/flake8
kstone@kstone-mbp ~> flake8 --version
2.5.0 (pep8: 1.5.7, pyflakes: 1.0.0, mccabe: 0.3.1) CPython 2.7.10 on Darwin
But SublimeLinter uses the system python (if another one isn't configured) rather than calling the entry point directly and thus doesn't register the appropriate virtualenv:
SublimeLinter: flake8 version query: /usr/bin/python $HOME/.local/bin/flake8 --version
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
File "$HOME/.local/bin/flake8", line 7, in <module>
from flake8.main import main
ImportError: No module named flake8.main
Basically it's calling python ~/.local/bin/flake8
instead of just executing ~/.local/bin/flake8
I updated pep8 to 1.6.2 via pip and then SL3 fails to lint.
The error message:
SublimeLinter: WARNING: import of flake8.engine module in flake8 failed, linter will not work with python 3 code
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
File "/usr/local/bin/flake8", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/flake8/main.py", line 24, in main
flake8_style = get_style_guide(parse_argv=True, config_file=DEFAULT_CONFIG)
File "/usr/local/lib/python2.7/site-packages/flake8/engine.py", line 110, in get_style_guide
kwargs['parser'], options_hooks = get_parser()
File "/usr/local/lib/python2.7/site-packages/flake8/engine.py", line 48, in get_parser
(extensions, parser_hooks, options_hooks, ignored) = _register_extensions()
File "/usr/local/lib/python2.7/site-packages/flake8/engine.py", line 32, in _register_extensions
checker = entry.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2344, in load
self.require(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2361, in require
items = working_set.resolve(reqs, env, installer)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 838, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pep8 1.6.2 (/usr/local/lib/python2.7/site-packages), Requirement.parse('pep8<1.6,>=1.5.7'))
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 158, in on_api_ready
m.plugin_loaded()
File "/Users/username/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/sublimelinter.py", line 34, in plugin_loaded
linter.initialize()
File "linter in /Users/username/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 94, in initialize
File "/usr/local/lib/python3.5/site-packages/pkg_resources/init.py", line 2354, in load
self.require(_args, *_kwargs)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/init.py", line 2371, in require
items = working_set.resolve(reqs, env, installer)
File "/usr/local/lib/python3.5/site-packages/pkg_resources/init.py", line 844, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pep8 1.6.2 (/usr/local/lib/python3.5/site-packages), Requirement.parse('pep8!=1.6.0,!=1.6.1,!=1.6.2,>=1.5.7'))
After a linting is done, the gutters and outlines are shown. But once I start typing again, all of them are gone, and I have to save to lint again. What I want is: when I start typing, only the gutter / outline of that specific line disappear, and others remain unchanged. If this cannot be achieved, then I want all the gutters / outlines to remain the same when I start typing.
Is that possible? Thanks
I know there are some opened issues about wrong highlight on unused imports, but I think this one is different.
If I have the import clause separated on multiple line, there will be a gutter showing a warning sign. But there will be no keyword highlighted, thus you cannot use Ctrl + K, n
to jump to that warning.
I'm trying to install via Package Control; I first install SublimeLinter 3. Then installed SublimeLinter-flake8. I get this error in the console:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 74, in reload_plugin
m = importlib.import_module(modulename)
File "./importlib/__init__.py", line 90, in import_module
File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 678, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "linter in /Users/thornomad/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 17, in <module>
File "/Users/thornomad/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/linter.py", line 124, in __init__
cls.reinitialize()
File "/Users/thornomad/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/lint/python_linter.py", line 98, in reinitialize
cls.initialize()
File "linter in /Users/thornomad/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-flake8.sublime-package", line 74, in initialize
RuntimeError: super(): empty __class__ cell
This is my first time using SublimeLint and am not sure what to do ... it doesn't appear to be working. Have tried this on two different machines. After this error I don't see SublimeLinter-flake8
in my Library/Application Support/Sublime Text 3/Packages. And every file I check it says "no errors".
Thanks for your help.
It would be nice if this linter color-coded errors based on severity, or the exact linter the error originated from (pep8 vs pyflakes vs mccabe). In general, I care far more about a pyflakes error than pep8/mccabe, since a pyflakes error usually means my code will error out.
Versions..
OS: OS X 10.10.5
Sublime Text: v3 build 3114
Sublimelinter Plugin: 3.7.4
Sublimelinter-flake8 Plugin: 2.0.1
system flake8: 3.0.0b1
Work-around: I dropped back to flake8 v2.4.1 and seems to be working just fine.
I'm seeing this a lot in sublime's console
SublimeLinter: flake8: wanted @python is 'None'
SublimeLinter: flake8: trying to use globally installed flake8
SublimeLinter: flake8: wanted @python is 'None'
SublimeLinter: flake8: trying to use globally installed flake8
SublimeLinter: flake8: wanted @python is 'None'
SublimeLinter: flake8: trying to use globally installed flake8
SublimeLinter: flake8: wanted @python is 'None'
SublimeLinter: flake8: trying to use globally installed flake8
Is there a way to get rid of this? I'm usually connected to Maya and have it's console report back to sublime's console and this is getting in my way.
Hello!
Flake8 usually reads configuration options from ~/.config/flake8 but when used with SublimeLinter-flake8 it seems as if the file wasn't been loaded.
Is that expected? How can I get it to read the file?
Thanks
Would make it much easier to know which codes to ignore. An example of the popup menu I'm talking about:
I think https://github.com/dreadatour/Flake8Lint has this built in.
My project wide flake8 settings are defined in a setup.cfg:
[flake8]
max-line-length = 100
This worked fine when I was using python2 flake8 (presumably as the executable was used), but now I've switched to a python3 flake8 these settings are being ignored:
SublimeLinter: flake8: __init__.py <builtin>
SublimeLinter: flake8 options: {'max_complexity': -1, 'reporter': <class 'SublimeLinter-flake8.linter.Flake8.get_report.<locals>.Report'>, 'jobs': '1'}
SublimeLinter: flake8 output:
__init__.py:106:80: E501 line too long (99 > 79 characters)
__init__.py:129:80: E501 line too long (99 > 79 characters)
__init__.py:164:80: E501 line too long (82 > 79 characters)
__init__.py:165:80: E501 line too long (84 > 79 characters)
__init__.py:198:80: E501 line too long (99 > 79 characters)
I prefer using setup.cfg for settings as they will also apply for flake8 runs from the command line or travis.
Hi,
When installing the Djaneiro plugin flake8 stops finding errors inside .py files. It seems it has to do with the new tmLanguage that Djaneiro adds: "Python Django". Would it be possible to add highlighting to files with the "Python Django" syntax, and not only "Python"? Would love to use SublimeLinter-flake8 together with Djaneiro!
Thanks for your great work!
In the README, the here
link in "You can read more about it here" is broken.
I want to ignore "line too long" messages but for some reason it doenst work.
This is from my SublimeLinter.sublime-settings
:
"flake8": {
"@disable": false,
"args": [],
"builtins": "",
"excludes": [],
"ignore": "E501",
"jobs": "1",
"max-complexity": -1,
"max-line-length": null,
"select": ""
},
The error code E501
is correct (I think) - if I enable debug mode and open the console:
script.py:26:80: E501 line too long (97 > 79 characters)
I installed flake8 via pip + the following extensions:
cvirus@leon:~$ flake8 --version 2.2.5 (pep8: 1.5.7, import-order: 0.5.1, pep257: 0.2.1, mccabe: 0.2.1, pyflakes: 0.8.1, naming: 0.2.2) CPython 2.7.6 on Linux
Unfortunately, SublimeLinter-flake8 will only highlight the errors for pyflakes, pep8, and mccabe .. While the rest of the extensions have no effect, except for the "import-order" extension where its errors are only shown in SublimeText console but are not highlighted in the editor:
SublimeLinter: flake8: models.py ['/usr/bin/python', '/usr/local/bin/flake8', '--config=setup.cfg', '--jobs=1', '-'] SublimeLinter: flake8 output: stdin:2:1: I100 Imports statements are in the wrong order. from django.conf should be before from django.db
If I run flake8 from the command line, I get the following:
cvirus@leon:~/projects/fer2etak$ flake8 fer2etak/nada/models.py fer2etak/nada/models.py:1:1: D100 Docstring missing fer2etak/nada/models.py:2:1: I100 Imports statements are in the wrong order. from django.conf should be before from django.db fer2etak/nada/models.py:6:1: D101 Docstring missing fer2etak/nada/models.py:10:1: D102 Docstring missing fer2etak/nada/models.py:14:1: D203 Expected 1 blank line *before* class docstring, found 0 fer2etak/nada/models.py:14:1: D204 Expected 1 blank line *after* class docstring, found 0 fer2etak/nada/models.py:14:1: D400 First line should end with '.', not 'g' fer2etak/nada/models.py:29:1: D102 Docstring missing fer2etak/nada/models.py:33:1: D101 Docstring missing fer2etak/nada/models.py:38:1: D102 Docstring missing
Non of the above errors are highlighted in the editor.
Is this a bug or I'm missing something ?
In the readme it says I
must ensure that flake8 is installed on your system.
However, before I installed flake8 to my local Python dist, the following was output to my console:
SublimeLinter: flake8 enabled: (None, None)
I do not think this message is useful because linting does not work even though I don't get an error. Also, when installing from within Package Control you don't get to see the readme.
Later, as I installed it, the message would turn into
SublimeLinter: flake8 enabled: ('c:\\Python33\\python.exe', 'c:\\Python33\\Scripts\\flake8-script.py')
yet it still doesn't work. It also appears that setting "@python": 2
in the user settings does not change the above to my 2.7 dist.
Note that it did work with the built-in Python and the flake8 version from Python Flake8 Lint
until I figured out this was because I didn't restart ST after disabling the package.
Then, if I were to specify other versions of Python on my system (2.7, 3.2 and 3.3 are available), where would I tell the linter where they are? Found it here.
And finally: Is it possible to flag a single file as being Python2? Does it read the #!/usr/bin/env python3
line? It seems like you can only set that for the whole project and directory.
flake8
supports various config files out of the box, e.g. .flake8
. But command line args have precedence over config file settings, and all settings within the SublimeLinter framework will end as command line args. This leads to a bad default UX bc this linter unfortunately applies some default settings on its own.
SublimeLinter-flake8/linter.py
Lines 57 to 59 in adb4890
We should therefore remove all default settings, t.i. set them to the empty string, so that by default the typically settings in tox.ini
, .flake8
or setup.cfg
will kick in.
IMO it should be best practice anyway to keep these settings outside of Sublime text bc the other people already use vscode ;-)
Hi,
At some point in the recent past, sublimelinter started choosing /usr/local/bin/flake8 regardless of the @python
version I have specified in my project settings. I think the linter used to use the python module (i.e. python -m flake8) with the correct python version.
While I have flake8 installed for both python2 and 3, /usr/local/bin/flake8 only works for the one I've most recently installed it for, since the pip install seems to put the python version in the shebang of that script, like so:
#!/usr/local/opt/python/bin/python2.7
# -*- coding: utf-8 -*-
import re
import sys
from flake8.main.cli import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
This makes flake8 linting not work for python3, or vice versa depending on what I've installed last.
I've tried a few different things, such as setting @python
inline, changing my shebang lines in scripts to a versioned python (i.e. #!/usr/local/bin/python3
), but /usr/local/bin/flake8 is always chosen as the linter.
I'm running python 2.7.12 and 3.5.2 installed via Homebrew on OSX 10.11, in case that information is relevant. I'm running the latest build of ST3, and SublimeLinter 3.7.4, and SublimeLinter-flake8 2.0.1
Let me know if I can provide further information.
Hey there guys, great extension.
Unfortunately it seems that flake8 2.2.0 has broken it. The extension appears to search for flake8-script.py which doesn't exist in the 2.2.0 release and therefore flake8 is simply not found at all.
Rolling back to flake8 2.1.0 works as expected:
pip install flake8==2.1.0
Any help would be greatly appreciated 😄
Cheers
Fotis
Despite what the readme says, this package is broken on flake8 2.1:
SublimeLinter: flake8: wanted executable is '/usr/bin/flake8'
SublimeLinter: flake8: __init__.py ['/usr/bin/flake8', '--jobs=1', '--max-line-length=79', '--max-complexity=15', '--ignore=E303,E501', '-']
SublimeLinter: flake8 output:
Usage: flake8 [options] input ...
flake8: error: no such option: --jobs
Perhaps this flag only exists for the python3 version of flake8?
For good reasons, settings like max-line-length
and max-complexity
should be not held within sublime settings, but in .flake8
or another config file.
The exception here should be the typical whitespace warnings Sublime will autocorrect for us on save. These are:
W291 | trailing whitespace |
---|
W293 | blank line contains whitespace |
---|
W391 | blank line at end of file |
---|
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.