Skip to content

Instantly share code, notes, and snippets.

@aflc
Created January 26, 2013 15:10
Show Gist options
  • Save aflc/4642843 to your computer and use it in GitHub Desktop.
Save aflc/4642843 to your computer and use it in GitHub Desktop.
SublimeText2とSublimeLinter - Python3の構文チェック - ref: http://qiita.com/items/f1bbd2917025494d021f
cd ~/Library/Application Support/Sublime Text 2/Packages/Python
cp Python.tmLanguage Python3.tmLanguage
{
"sublimelinter_executable_map": {
"python3": "python3版flake8へのパス"
}
}
NUM = STR = ELLIPSIS = ignore
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