Created
January 26, 2013 15:10
-
-
Save aflc/4642843 to your computer and use it in GitHub Desktop.
SublimeText2とSublimeLinter - Python3の構文チェック - ref: http://qiita.com/items/f1bbd2917025494d021f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~/Library/Application Support/Sublime Text 2/Packages/Python | |
cp Python.tmLanguage Python3.tmLanguage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sublimelinter_executable_map": { | |
"python3": "python3版flake8へのパス" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NUM = STR = ELLIPSIS = ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from base_linter import BaseLinter, INPUT_METHOD_FILE | |
CONFIG = { | |
'language': 'Python3', | |
'executable': 'flake8', | |
'test_existence_args': ['--version'], | |
'lint_args': '{filename}', | |
'input_method': INPUT_METHOD_FILE # 保存時のみ。リアルタイムチェックしたい場合はINPUT_METHOD_TEMP_FILEにする | |
} | |
class Linter(BaseLinter): | |
def parse_errors(self, view, errors, lines, errorUnderlines, violationUnderlines, warningUnderlines, errorMessages, violationMessages, warningMessages): | |
for line in errors.splitlines(): | |
match = re.match(r'^.+:(?P<line>\d+):(?P<offset>\d*):?\s+(?P<error>.+)', line) | |
if match: | |
error, line, offset = match.group('error'), match.group('line'), match.group('offset') | |
if not error.startswith('E501'): | |
self.add_message(int(line), lines, '[{0}: {1}]'.format(offset, error), errorMessages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment