SublimeLinter/sublimelinter/modules/python3.py
python3.py
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 #Only when saving. INPUT if you want to check in real time_METHOD_TEMP_Make it 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)
E501 is excluded if you like.
cd ~/Library/Application Support/Sublime Text 2/Packages/Python
cp Python.tmLanguage Python3.tmLanguage
I'm not sure, so I changed only name and scopeName to Python3 and source.python3 OK if Python3 appears in Set Syntax
{
"sublimelinter_executable_map": {
"python3": "Path to flake8 for python3"
}
}
The workaround is to set the environment variable PYTHONIOENCODING to utf-8 and LC_CTYPE to en_US.utf-8. For Mac users, write in /etc/launchd.conf. If you don't like the impact, you can write your own startup script (equivalent to the flake8 command) and write the encoding settings inside. Set the internal environment so that sys.getdefaultencoding () =='utf-8', locale.getpreferredencoding (False) =='utf-8'.
This looks like a bug in flake8. flake8 / pyflakes.py: per 319
NUM = STR = ELLIPSIS = ignore
I added BYTES to it and it worked.