SublimeLinter-pyflakes
SublimeLinter-pyflakes copied to clipboard
[Feature Request] Support for warnings
Currently, there is no differentiating between errors and warnings from pyflakes, however Atom's pyflakes linter managed to detected warnings from errors by looking for the following strings:
'used',
'redefines',
'shadowed'
'may be'
in the output. Maybe something like that could be integrated.
That sounds like a good addition. Can you make a PR? If you don't know how to start just ask, I can guide you through.
@kaste I tried, but the documentation isn't good, and I haven't done any work with regex. Really sorry.
Basically you have to implement split_match
def split_match(self, match):
match, line, col, error, warning, message, near = super().split_match(match)
if not match:
return None
# now parse and interpret 'message'
# 'error' or 'warning' represent a 'code' or linter rule like 'W031' or
# '(no-redef)' etc.
if message is an error:
error = 'error'
else:
warning = 'warning'
return match, line, col, error, warning, message, near
@kaste It uses regex though, I was able to remove all the code except for the variables and regex at the start and it all worked fine.
#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by Aparajita Fishman
# Copyright (c) 2015-2016 The SublimeLinter Community
# Copyright (c) 2013-2014 Aparajita Fishman
#
# License: MIT
#
"""This module exports the Pyflakes plugin linter class."""
from io import StringIO
from SublimeLinter.lint import PythonLinter
class Pyflakes(PythonLinter):
"""Provides an interface to the pyflakes python module/script."""
syntax = 'python'
cmd = 'pyflakes@python'
version_args = '--version'
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 0.7.3'
regex = r'''(?x)
.+?:\s* # filename
(?P<line>\d+):\s* # line number
# The rest of the line is the error message.
# Within that, capture anything within single quotes as 'near'.
(?P<message>[^\'\n\r]+(?P<near>\'.+?\')?.*)
# The error message may be followed by the offending line of code...
(?:\r?\n.*
# and then another line with a caret (preceded by spaces)
# pointing to the position where the error occurred.
\r?\n(?P<col>[ ]+)\^)?
'''
multiline = True
module = 'pyflakes.api'
check_version = True
# Internal
reporter = None
Sorry I don't know what you did here
@kaste I'm using SL4. That removes the need for the functions.
That's a bit odd. You should just use the version from master.
@kaste I know, I was just having problems with pyflakes not running because it couldn't find the executable. I had to set it manually, and I needed SL4 to do that.
Currently, there is no differentiating between errors and warnings from pyflakes, however Atom's pyflakes linter managed to detected warnings from errors by looking for the following strings:
'used', 'redefines', 'shadowed' 'may be'in the output. Maybe something like that could be integrated.
Hi! :) take a look at #18