biermeester / pylinter Goto Github PK
View Code? Open in Web Editor NEWA pylint plugin for Sublime Text 2 and 3
A pylint plugin for Sublime Text 2 and 3
Pylinter does not work correctly with the newly released 1.0 version of Pylint as no lint messages are displayed within SublimeText.
I tracked the issue down to the following two changes in Pylint:
--include-ids
command line switch, it just quits with an error message.--output-format=parseable
. The currently used regex for parsing error messages does not work with the new format.I've got a working patch for this problem and I'll submit a pull request shortly. Thanks for your great work on Pylinter, I love it! :)
It took me a few minutes to figure out why my project-specific settings weren't taking effect. The code that manually searches the project folders for sublime-project files doesn't handle the case where a sublime-project only includes subfolders (and not the folder the sublime-project file resides in).
I'm not sure if you had a reason for doing it this way. An alternative would be to do:
sublime.active_window().active_view().settings().get('pylinter')
to get project-specific settings. This might remove about 30 lines of code.
I can submit a patch if you'd like.
This is a "Pylint not found at 'lint.py'" error. On Mac OSX.
Basically, I installed pylinter into ST3 (commit: be4e76e) and pylint into a virtualenv. pylint_path is not picked up properly when Sublime starts, resulting in:
reloading plugin Pylinter.multiconf
reloading plugin Pylinter.pylinter
pylint_pathSTART
None
pylint_pathEND
error: Pylint not found at 'lint.py'.
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 "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1023, in load_module
File "<frozen importlib._bootstrap>", line 1004, in load_module
File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 869, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "/Users/dpwrussell/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 164, in <module>
PYLINT_VERSION = PylSet.get_lint_version()
File "/Users/dpwrussell/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 155, in get_lint_version
os.path.dirname(PylSet.get_lint_path()),
File "X/posixpath.py", line 151, in dirname
AttributeError: 'NoneType' object has no attribute 'rfind'
plugins loaded
This snippet in there is some debug code I added to do:
settings_obj.get('pylint_path')
pylint_pathSTART
None
pylint_pathEND
As you can see, the path is initially None and thus pylinter does not work.
I've tried setting it in project settings in a pylinter section, in Pylinter User settings (/Library/Application Support/Sublime Text 3/Packages/User/Pylinter.sublime-settings) and finally in the main settings file itself (/Library/Application Support/Sublime Text 3/Packages/Pylinter.sublime-settings). All to no avail.
In the latter two, my config section looked like this
{
//...
"python_bin": "/Users/dpwrussell/.virtualenvs/test_sublime/bin/python",
"pylint_path": "/Users/dpwrussell/.virtualenvs/test_sublime/lib/python3.3/site-packages/pylint/lint.py",
}
Oddly, when adding my debug code I discovered something surprising. When I edited pylinter.py, it starts working:
Writing file /Users/dpwrussell/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py with encoding UTF-8 (atomic)
reloading plugin Pylinter.pylinter
pylint_pathSTART
/Users/dpwrussell/.virtualenvs/test_sublime/lib/python3.3/site-packages/pylint/lint.py
pylint_pathEND
If you restart Sublime it stops working until you modify pylinter.py again.
Happy to help debug this if you need someone on OSX.
Just upgraded to pylint 1.0 and the latest pylinter. Upon save, I'm now receiving an error:
lint.py: error: no such option: --include-ids
It's trivial, but the error required me to remove pylinter and then re-install.
When using pylint plugins (for example pylint_django) it will crash on every check. For the proper work pylint must be run by "pylint" command, not lint.py. I solved this problem by specifying "pylint_path" like this: "/usr/local/bin/pylint". Then everything works fine.
Maybe we should change the way it run for more correct (according to the pylint documentation: by pylint script)?
I'm getting the following after installing:
reloading plugin Pylinter.pylinter
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 "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1023, in load_module
File "<frozen importlib._bootstrap>", line 1004, in load_module
File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 869, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "/Users/cwd/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 78, in <module>
if PYLINT_VERSION[0] == 0:
IndexError: tuple index out of range
I installed the package via Package Control, I save a .py file and it complains I need to set path to lint.py ... OK, I set the path and it no longer complains when saving.
But I don't see anything.
I put a deliberate error in the file and save again, still nothing.
pylint from the command line produces output and picks up the error.
cmd+alt+z shows 'PyLinting' and a circle icon briefly in the status bar
I'm assuming it should display some output, maybe highlight the error-ing line?
Any idea what could be wrong?
If I disable a pylint error/warning/etc flags within a file using # pylint: disable=<flag>
, and have specified in my Preferences.sublime-settings
an ignore of ["I0011"]
, with I0011
being 'Locally disabling' that flag, I still see that line highlighted upon running Pylinter, with I0011
displayed as the flag.
I expected pylint flags I had ignored to not be highlighted any more. Is there a way to achieve this in the settings?
I always get the following error in console when I attempt to run Pylinter with Sublime Text 2 on Windows 7:
Exception in thread Thread-9:
Traceback (most recent call last):
File ".\threading.py", line 532, in bootstrap_inner
File ".\pylinter.py", line 332, in run
File ".\subprocess.py", line 633, in __init
File ".\subprocess.py", line 842, in _execute_child
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect
This error is happening with the latest version of Pylinter. It was not happening with the previous version (2012-08-31) of Pylinter.
When my python file is in a uncode path,such as F://Temp/携程/process.py
the pylinter just doesn't work!
I open the console, it show like this:
Writing file /F/Temp/携程/process.py with encoding UTF-8
Exception in thread Thread-19:
Traceback (most recent call last):
File ".\threading.py", line 532, in bootstrap_inner
File ".\pylinter.py", line 487, in run
File ".\subprocess.py", line 633, in __init
File ".\subprocess.py", line 842, in _execute_child
UnicodeEncodeError: 'ascii' codec can't encode characters in position 163-164: ordinal not in range(128)
could you please solve this problem? i'm so confused.
Is it possible to chose how the error messages are listed, i.e by line numbers or how severe they are?
When I save my code (and thus lint it, at least that what Subime says in the bottom panel) no errors is reported, even thouth I introduced a reference to an undefined variable. In order to test if Pylint works, I ran pylint on the code manually, and got this:
No config file found, using default configuration
************* Module afl7
W: 10,0: Found indentation with tabs instead of spaces
W: 11,0: Found indentation with tabs instead of spaces
W: 12,0: Found indentation with tabs instead of spaces
W: 13,0: Found indentation with tabs instead of spaces
W: 23,0: Found indentation with tabs instead of spaces
W: 31,0: Found indentation with tabs instead of spaces
W: 32,0: Found indentation with tabs instead of spaces
C: 1,0: Missing docstring
C: 16,0: Invalid name "n" for type constant (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C: 17,0: Invalid name "m" for type constant (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C: 18,0: Invalid name "g" for type constant (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C: 19,0: Invalid name "v" for type constant (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C: 20,0: Comma not followed by a space
v[0,:] = np.array([100, 100])
^^
E: 22,3: Undefined variable 'a'
C: 32,1: Comma not followed by a space
print 'v[0:4,:] :\n', v[0:4,:]
^^
W: 14,0: Unused import plt
I'we given the exact path for the lint.py in the settings, and tried both with and without the my linting-ignore file:
{
// Full path to the lint.py module in the pylint package
"pylint_path": "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pylint/lint.py",
// Optional full path to a Pylint configuration file
// "pylint_rc": "/Users/allan/.pylint_rc",
// Set to true to automtically run Pylint on save
"run_on_save": true,
// Set to true to use graphical error icons
"use_icons": true,
// Ignore Pylint error types. Possible values:
// "R" : Refactor for a "good practice" metric violation
// "C" : Convention for coding standard violation
// "W" : Warning for stylistic problems, or minor programming issues
// "E" : Error for important programming issues (i.e. most probably bug)
// "F" : Fatal for errors which prevented further processing
"ignore": []
}
I Love Pylint – any suggestions on fixing this will be greatly appreciated :)
Not sure what changed, but pylinter is no longer running with the latest update.
Sublime Text 3 - build 3059
On adding a pylint disable with the (keyboard) shortcut, it'd be useful if instead of the code the symbolic name was used. For example,
a = 1 #pylint: disable=C0103
b = 2 #pylint: disable=invalid-name
The second one is much more readable. This matters when there are a number of things going on in a line; in this case I'd want to know what warning was disabled.
This was probably the original intention of this setting but currently it only allows one argument to be passed as a string. More than one argument causes both arguments to fail unless the first argument ends in a comma and even then any additional argument fails.
Works:
"pylint_extra": "--ignored-classes=MsgProto"
Both args fail:
"pylint_extra": "--ignored-classes=MsgProto --extension-pkg-whitelist=lxml,cassandra"
First arg works:
"pylint_extra": "--ignored-classes=MsgProto, --extension-pkg-whitelist=lxml,cassandra"
This setting should instead a list of strings instead of a string
"pylint_extra": ["--ignored-classes=MsgProto", "--extension-pkg-whitelist=lxml,cassandra"]
Pylinter was working until I restarted ST just now. I now get an exception on load, and whenever I try to lint manually I get the following exception:
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "/home/aru/.config/sublime-text-3/Packages/Pylinter/pylinter.py", line 194, in run
settings = PylSet.read_settings()
File "/home/aru/.config/sublime-text-3/Packages/Pylinter/pylinter.py", line 90, in read_settings
ignore = [t.lower() for t in cls.get_or('ignore', [])]
TypeError: 'NoneType' object is not iterable
Sublime Text 2 on Linux, the default Ctrl+Alt+x does not toggle on or off the messages.
I get the following error when Pylinter tries to find lint.py:
reloading plugin Pylinter.pylinter
- PyLinter: Pylint executable *not* found
- PyLinter: Seaching for lint.py module...
Traceback (most recent call last):
File "/Applications/Sublime Text 3.app/Contents/MacOS/sublime_plugin.py", line 115, in reload_plugin
m.plugin_loaded()
File "/Users/christoph/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 77, in plugin_loaded
DEFAULT_PYLINT_COMMAND = PylSet.get_default_pylint_command()
File "/Users/christoph/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 207, in get_default_pylint_command
if not pylint_path:
UnboundLocalError: local variable 'pylint_path' referenced before assignment
Fatal pylint error:
fullpath/to/virtualenv/bin/python: can't find 'main' module in ''.
I get this error every time. This error started occurring from 2 days back, probably after the new update.
PS. I'm running sublime text from within the virtualenv as you have mentioned.
Simple test case:
# coding: utf8
# TODO Comment with non ASCII characters in it: °C.
This does not show up in the status line and invoking the list of all warnings doesn't work any more.
When moving the cursor onto that line the Sublime Text console reads:
Traceback (most recent call last):
File "./sublime_plugin.py", line 200, in on_selection_modified
File "./sublime_plugin.py", line 154, in run_timed_function
File "./sublime_plugin.py", line 199, in <lambda>
File "./pylinter.py", line 577, in on_selection_modified
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 53: ordinal not in range(128)
And when trying to invoke the list of all Pylint messages with Ctrl+Alt+C
the console contains:
Traceback (most recent call last):
File "./sublime_plugin.py", line 356, in run_
File "./pylinter.py", line 283, in run
File "./pylinter.py", line 373, in popup_error_list
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 53: ordinal not in range(128)
This case seems to be unhandled when loading the version of pylint:
File "~/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 151, in read_settings
if PYLINT_VERSION[0] != 0:
TypeError: 'NoneType' object is not subscriptable
Is it possible to expand the ignore variable to allow specific error in addition to general error types? For example, I hate error C0103 because it wants variables to be all uppercase, unless I am just using variables wrong, but I suppose this isn't the place to figure that out.
As of pylint 1.0.0, the option "--include-ids" is no longer supported. Their docs are not yet updated, but it's mentioned in the ChangeLog (https://bitbucket.org/logilab/pylint/src/656d711815bc70f2f26871bb2a028b3411189710/ChangeLog?at=default)
Edit:
Hmm. It might be that the version is not detected properly on my system - if I force it to 1.0.0 in pylinter.py it works ok.
The status message for the pylint result only shows for column 1, as far as I can tell. Tried this with 2 columns and 3 columns.
Before I add this to my fork I wanted to ask if its currently possible to define a platform-dependent pylint path. I'm synchronizing my sublimetext settings / packages via dropbox and I'm currently working on Linux and Windows. Pylint is installed in different directories on each platform, so I have to change the path accordingly, but this then gets synchronized via dropbox...and so on. This could be avoided by using a platform-dependent settings file, like it is currently done for the shortcuts.
Pylinter overwrites the built-in key binding "super+alt+c" which toggles case-sensitivity when doing a global search. The built-in key binding uses a context to specify where it works, maybe that could work for pylinter?
Here's the config for the built-in key binding:
{ "keys": ["super+alt+c"], "command": "toggle_case_sensitive", "context":
[
{ "key": "setting.is_widget", "operator": "equal", "operand": true }
]
},
So, maybe this would work for pylinter?:
{ "keys": ["super+alt+c"], "command": "pylinter", "args": {"action": "list"}, "context":
[
{ "key": "setting.is_widget", "operator": "equal", "operand": false }
]
},
I worked around the issue by redefining the default key binding in my user settings and setting new bindings for pylinter:
// Reset binding for case-sensitive search, since pylinter clobbers it
{ "keys": ["super+alt+c"], "command": "toggle_case_sensitive", "context":
[
{ "key": "setting.is_widget", "operator": "equal", "operand": true }
]
},
// Add chord-style bindings for Pylinter:
{ "keys": ["super+alt+l", "super+alt+l"], "command": "pylinter"},
{ "keys": ["super+alt+l", "super+alt+k"], "command": "pylinter", "args": {"action": "toggle"} },
{ "keys": ["super+alt+l", "super+alt+o"], "command": "pylinter", "args": {"action": "list"} },
{ "keys": ["super+alt+l", "super+alt+i"], "command": "pylinter", "args": {"action": "ignore"} }
After a long session I noticed pylint taking longer and longer to process; eventually it stopped entirely. I poked around a bit and found that the PYTHONPATH was growing on every run. Something presumably unrelated was also including single character entries to my pythonpath.
in pylinter.py line 184 I added:
original = os.environ['PYTHONPATH']
pythonpaths = set()
for element in original.split(';'):
for subelement in element.split(':'):
if not subelement in [''] and len(subelement) > 1:
#speak('ElementA: ', subelement)
pythonpaths.add(subelement)
for element in self.python_path:
for subelement in element.split(':'):
if not subelement in [''] and len(subelement) > 1:
#speak('ElementB: ', subelement)
pythonpaths.add(subelement)
os.environ['PYTHONPATH'] = ":".join(pythonpaths)
speak("Running command:\n ", " ".join(command))
and all is now well in my world.
Similar to recent issue: #13
Example:
Writing file /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py with encoding UTF-8 (atomic)
- PyLinter: Verbose is True
- PyLinter: Running Pylinter on /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py
- PyLinter: Current PYTHONPATH is '/Users/kry/mitx_all/edx-platform/common/lib:/Users/kry/mitx_all/edx-platform/lms/djangoapps:/Users/kry/mitx_all/edx-platform/cms/djangoapps:/Users/kry/mitx_all/edx-platform/common/djangoapps:/Users/kry/mitx_all/edx-platform/lms/lib:/Users/kry/mitx_all/edx-platform/cms/lib'
- PyLinter: Updated PYTHONPATH is '/Users/kry/mitx_all/edx-platform/common/lib:/Users/kry/mitx_all/edx-platform/lms/djangoapps:/Users/kry/mitx_all/edx-platform/cms/djangoapps:/Users/kry/mitx_all/edx-platform/common/djangoapps:/Users/kry/mitx_all/edx-platform/lms/lib:/Users/kry/mitx_all/edx-platform/cms/lib'
- PyLinter: Running command with Pylint (0, 28, 0)
- PyLinter: /Users/kry/mitx_all/python/bin/python /Users/kry/mitx_all/python/lib/python2.7/site-packages/pylint/lint.py --output-format=parseable --include-ids=y --rcfile=/Users/kry/mitx_all/edx-platform/pylintrc /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py
reloading plugin Pylinter.pylinter
- PyLinter: Pylint executable *not* found
- PyLinter: Seaching for lint.py module...
- PyLinter: Pylint path /Library/Python/2.7/site-packages/pylint/lint.py found
- PyLinter: Pylint version (0, 28, 0) found
- PyLinter: No errors found
While when running command separately:
$ /Users/kry/mitx_all/python/bin/python /Users/kry/mitx_all/python/lib/python2.7/site-packages/pylint/lint.py --output-format=parseable --include-ids=y --rcfile=/Users/kry/mitx_all/edx-platform/pylintrc /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py
/Users/kry/Library/Application:1: [F0001(fatal)] No module named /Users/kry/Library/Application
Support/Sublime:1: [F0001(fatal)] No module named Support/Sublime
Text:1: [F0001(fatal)] No module named Text
3/Packages/Pylinter/pylinter.py:1: [F0001(fatal)] No module named 3/Packages/Pylinter/pylinter.py
Investigation shows that regexp P_PYLINT_ERROR for path PYLINT_VERSION[0] == 0:
(I use pylint 0.28) was incorrect:
In [179]: %paste
P_PYLINT_ERROR = re.compile(r"""
^(?P<file>.+?):(?P<line>[0-9]+):\ # file name and line number
\[(?P<type>[a-z])(?P<errno>\d+) # message type and error number
# e.g. E0101
(,\ (?P<hint>.+))?\]\ # optional class or function name
(?P<msg>.*) # finally, the error message
""", re.IGNORECASE | re.VERBOSE)
## -- End pasted text --
In [180]: P_PYLINT_ERROR
Out[180]:
re.compile(r'\n ^(?P<file>.+?):(?P<line>[0-9]+):\ # file name and line number\n \[(?P<type>[a-z])(?P<errno>\d+) # message type and error number\n # e.g. E0101\n (,\ (?P<hint>.+))?\]\ # optional class or function name\n (?P<msg>.*) # finally, the error message\n ',
re.IGNORECASE|re.VERBOSE)
In [181]: x = """/Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py:18: [F0401(import-error)] Unable to import 'sublime'"""
In [182]: print x
/Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py:18: [F0401(import-error)] Unable to import 'sublime'
In [183]: re.search(P_PYLINT_ERROR, x)
After changing it to:
P_PYLINT_ERROR = re.compile(r"""
^(?P<file>.+?):(?P<line>[0-9]+):\s*\ # file name and line number
\[(?P<type>[a-z\(\)-])(?P<errno>\d+) # message type and error number
# e.g. E0101
(?P<hint>.+)?\]\ # optional class or function name
(?P<msg>.*) # finally, the error message
""", re.IGNORECASE | re.VERBOSE | re.DOTALL)
All starts to work:
Writing file /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py with encoding UTF-8 (atomic)
- PyLinter: Verbose is True
- PyLinter: Running Pylinter on /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py
- PyLinter: Current PYTHONPATH is '/Users/kry/mitx_all/edx-platform/common/lib:/Users/kry/mitx_all/edx-platform/lms/djangoapps:/Users/kry/mitx_all/edx-platform/cms/djangoapps:/Users/kry/mitx_all/edx-platform/common/djangoapps:/Users/kry/mitx_all/edx-platform/lms/lib:/Users/kry/mitx_all/edx-platform/cms/lib'
- PyLinter: Updated PYTHONPATH is '/Users/kry/mitx_all/edx-platform/common/lib:/Users/kry/mitx_all/edx-platform/lms/djangoapps:/Users/kry/mitx_all/edx-platform/cms/djangoapps:/Users/kry/mitx_all/edx-platform/common/djangoapps:/Users/kry/mitx_all/edx-platform/lms/lib:/Users/kry/mitx_all/edx-platform/cms/lib'
- PyLinter: Running command with Pylint (0, 28, 0)
- PyLinter: /Users/kry/mitx_all/python/bin/python /Users/kry/mitx_all/python/lib/python2.7/site-packages/pylint/lint.py --output-format=parseable --include-ids=y --rcfile=/Users/kry/mitx_all/edx-platform/pylintrc /Users/kry/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py
reloading plugin Pylinter.pylinter
- PyLinter: Pylint executable *not* found
- PyLinter: Seaching for lint.py module...
- PyLinter: Pylint path /Library/Python/2.7/site-packages/pylint/lint.py found
- PyLinter: Pylint version (0, 28, 0) found
- PyLinter: F0401: Unable to import 'sublime'
- PyLinter: F0401: Unable to import 'sublime_plugin'
- PyLinter: W0603: Using the global statement
- PyLinter: C0111: Missing docstring
- PyLinter: C0111: Missing docstring
- PyLinter: C0111: Missing docstring
- PyLinter: C0111: Missing docstring
- PyLinter: W0603: Using the global statement
- PyLinter: C0103: Invalid name "p" for type variable (should match [a-z_][a-z0-9_]{2,30}$)
- PyLinter: C0111: Missing docstring
- PyLinter: C0111: Missing docstring
- PyLinter: W0602: Using global for 'PYLINTER_ERRORS' but no assignment is done
- PyLinter: C0103: Invalid name "p" for type variable (should match [a-z_][a-z0-9_]{2,30}$)
- PyLinter: C0103: Invalid name "m" for type variable (should match [a-z_][a-z0-9_]{2,30}$)
- PyLinter: C0111: Missing docstring
- PyLinter: W0603: Using the global statement
Hi.
When I try to use the package, I get this message box and nothing else:
Fatal pylint error:
ValueError: Attempted relative import in non-package
Is this how it should be, or a bug?
Hi,
I'm having this issue on ST3 (3047), on both Windows (8) and Linux (Ubuntu 13.04).
ST3 starts, loads the plugin without issue, then when I ctrl + alt + z, it says in the console:
Traceback (most recent call last): File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 549, in run_ return self.run(edit) File "C:\Users\john\AppData\Roaming\Sublime Text 3\Packages\Pylinter\pylinter.py", line 194, in run settings = PylSet.read_settings() File "C:\Users\john\AppData\Roaming\Sublime Text 3\Packages\Pylinter\pylinter.py", line 86, in read_settings python_path = PATH_SEPERATOR.join([str(p) for p in python_path]) TypeError: 'NoneType' object is not iterable
If I reload the plugin (for instance by disabling and re-enabling it, or by changing something in pylinter.py and saving the file), it works well. I'm quite confident I didn't do any mistake settings-wise, but I can post it here on demand.
Anyway, if anyone experiences the same problem as I do, please speak up.
Also, thanks a lot for this handy plugin!
Title pretty much explains the problem -- Lint errors are not being shown on the gutter of new view into the file. Is this a Sublime limitation?
Feature request
Situation: Multiple pylint errors are detected on the same line (e.g. C0321 and E0602 ).
Rationale: It is usually more important to see Error over Warning or "line too long" message.
Actual behaviour: Single unsorted severity message is shown (usually this is the lowest severity, e.g C0321 instead of E0602).
Desired behaviour: Pick one message to show in the following order
OR list all of them (starting with the most severe one) in status-line using some special icon to indicate that multiple errors appear on the same line.
Workaround available: Use ctrl+alt+c to see drop-down with all messages (not very handy though for delivering in-place alerts).
When attempting to ignore in Build 3047, I get the following stacktrace:
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 543, in run_
return self.run(edit, **args)
File "/home/aru/.config/sublime-text-3/Packages/Pylinter/pylinter.py", line 208, in run
self.add_ignore()
File "/home/aru/.config/sublime-text-3/Packages/Pylinter/pylinter.py", line 337, in add_ignore
edit = self.view.begin_edit()
TypeError: begin_edit() missing 2 required positional arguments: 'edit_token' and 'cmd'
I'm using ST3 on Ubuntu 13.04. When I tried to disable "C0103" it worked fine like this:
{
"disable": ["C0103"]
}
However, when I try to disable "E501" (line too long), I get an error popup, "pylint.utils.UnknownMessage: No such message id E501"
I have this in my "Packages/User/Pylinter.sublime-settings" file:
{
"disable": ["E501"]
}
A setting for passing extra pylint arguments (pylint_extra) was introduced in 44fc98c and then lost in 0dd8f8d and only partially restored in 4e2ca28
The piece still lost added the extra arguments to the command option array leaving this functionality crippled.
Additionally the sublime-settings files were never updated to reveal this setting.
I use Pylinter to check code,When I build a code,I got an error message.
'''
Traceback (most recent call last):
File "D:\Soft\Python3\Lib\site-packages\pylint\lint.py", line 49, in
from pylint import ecption
ImportError: cannot import name ecption
'''
How I can resolve this problem?
Hello!
Thank you for a good project. It's very helpful for python developers who want to make the best code.
I turned on function "use_icons": true
and "disable_outline": true
and se icons in line, where I have errors (or notification icon).
Please make these icons more small and accurate. I think that gray icon will be good for warnings, and red icon for errors that should be fixed asap.
Also I use other plugins that show icons in the line. For example, GitGutter, that shown me what lines have added, removed or changed compared to GIT version. How it will work in case, when I need to see two icons from different plugins at the same time?
Thank you.
In my case I see warning and error messages on modules, that can not be imported, because these modules installed inside virtualevn specific for opened project.
I have multiple virtualenvs and multiple python projects inside each of Sublime Project.
Please add ability to set specific path to virtualenv folder for each python project separately. And also, for all projects inside one Sublime Project configuration file.
This will help me and other developers to be more satisfied.
Many thanks for your good work!
Anton Danilchenko
Hi,
This is probably not the way it should ultimately be done, however, I got this plugin working with (not so much effort) using the following changes:
multiconf.py | 6 +++---
pylinter.py | 22 ++++++++++++----------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/multiconf.py b/multiconf.py
index f88d277..0287df6 100755
--- a/multiconf.py
+++ b/multiconf.py
@@ -2,7 +2,7 @@ import socket
import sublime
import re
-""" Multiconf is a module that allows you to read platforma and/or host
+r""" Multiconf is a module that allows you to read platforma and/or host
specific configuration values to be used by Sublime Text 2 plugins.
Using this module's `get` function, allows the user to replace any settings
@@ -58,7 +58,7 @@ def get(settings_obj, key, default=None, callback=None):
# Parameter validation
if not isinstance(settings_obj, (dict, sublime.Settings)):
raise AttributeError("Invalid settings object")
- if not isinstance(key, basestring):
+ if not isinstance(key, str):
raise AttributeError("Invalid callback function")
if callback != None and not hasattr(callback, '__call__'):
raise AttributeError("Invalid callback function")
@@ -105,7 +105,7 @@ class Qualifications(object):
@classmethod
def add_qual(cls, key, callback):
- if isinstance(key, basestring) and re.match(r"^[a-zA-Z][a-zA-Z\d_]*$", key) == None:
+ if isinstance(key, str) and re.match(r"^[a-zA-Z][a-zA-Z\d_]*$", key) == None:
raise QualException("'%s' is not a valid function name." % key)
if not hasattr(callback, '__call__'):
raise QualException("Bad function callback.")
diff --git a/pylinter.py b/pylinter.py
index a04c1aa..41ffafa 100755
--- a/pylinter.py
+++ b/pylinter.py
@@ -8,7 +8,7 @@
For more information, go to https://github.com/biermeester/Pylinter#readme
"""
-
+
import os.path
import re
import threading
@@ -17,7 +17,7 @@ import collections
import sublime
import sublime_plugin
-import multiconf
+from . import multiconf
# To override this, set the 'verbose' setting in the configuration file
PYLINTER_VERBOSE = False
@@ -26,7 +26,7 @@ PYLINTER_VERBOSE = False
def speak(*msg):
""" Log messages to the console if VERBOSE is True """
if PYLINTER_VERBOSE:
- print " - PyLinter: ", " ".join(msg)
+ print(" - PyLinter: ", " ".join(msg))
# Regular expression to disect Pylint error messages
P_PYLINT_ERROR = re.compile(r"""
@@ -58,7 +58,7 @@ try:
if out != "":
PYLINT_PATH = os.path.join(out.strip(), # pylint: disable=E1103
- "lint.py")
+ b"lint.py")
except ImportError:
pass
@@ -89,7 +89,7 @@ class PylSet(object):
def get(cls, setting_name):
value = cls.get_or(setting_name, None)
if value is None:
- raise PylSetException("No value found for '%s'" % setting_name)
+ raise PylSetException(b"No value found for '%s'" % setting_name)
return value
@classmethod
@@ -126,7 +126,7 @@ class PylinterCommand(sublime_plugin.TextCommand):
elif action == 'ignore':
self.add_ignore()
else:
- speak("Running Pylinter on %s" % self.view.file_name())
+ speak("Running Pylinter on {}".format(self.view.file_name()))
if self.view.file_name().endswith('.py'):
thread = PylintThread(self.view, *settings)
@@ -144,7 +144,8 @@ class PylinterCommand(sublime_plugin.TextCommand):
speak("Verbose is", str(PYLINTER_VERBOSE))
python_bin = PylSet.get_or('python_bin', 'python')
python_path = PylSet.get_or('python_path', [])
- python_path = PATH_SEPERATOR.join([str(p) for p in python_path])
+ if python_path is not None:
+ python_path = PATH_SEPERATOR.join([str(p) for p in python_path])
working_dir = PylSet.get_or('working_dir', None)
pylint_path = PylSet.get_or('pylint_path', None) or PYLINT_PATH
pylint_rc = PylSet.get_or('pylint_rc', None) or ""
@@ -336,7 +337,7 @@ class PylintThread(threading.Thread):
os.environ['PYTHONPATH'] = PATH_SEPERATOR.join(pythonpaths)
speak("Updated PYTHONPATH is '%s'" % os.environ['PYTHONPATH'])
- speak("Running command:\n ", " ".join(command))
+ speak("Running command:\n{}".format(command))
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -344,8 +345,9 @@ class PylintThread(threading.Thread):
cwd=self.working_dir)
output, eoutput = p.communicate()
- lines = [line for line in output.split('\n')] # pylint: disable=E1103
- elines = [line for line in eoutput.split('\n')] # pylint:disable=E1103
+ lines = [line for line in output.decode().split('\n')] # pylint: disable=E1103
+
+ elines = [line for line in eoutput.decode().split('\n')] # pylint:disable=E1103
# Call set_timeout to have the error processing done
# from the main thread
sublime.set_timeout(lambda: self.process_errors(lines, elines), 100)
--
1.7.11.7
'''
The output of pylint
is treated as ASCII only which is not true if the checked source code contains characters outside of ASCII. At least at problematic places.
Simple test case:
# coding: utf-8
NAME='späm'
leads to the following in the ST console:
Writing file /home/bj/test.py with encoding UTF-8
************* Module test
Exception in thread Thread-46:
Traceback (most recent call last):
File ".\threading.py", line 532, in __bootstrap_inner
File "./pylinter.py", line 427, in run
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 96: ordinal not in range(128)
That line in pylinter
reads:
lines = [line for line in output.decode().split('\n')] # pylint: disable=E1103
The output of pylint
where decoding fails looks like this:
/home/bj/test.py:2:C0322:Operator not preceded by a space
NAME='späm'
^
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.