Plugins/CheckerPlugins/CodeStyleChecker/pycodestyle.py

changeset 5290
174dae2b91c3
parent 5288
ff831e3e383e
child 5303
83ab5275f255
equal deleted inserted replaced
5289:26e4a082ba54 5290:174dae2b91c3
77 from configparser import RawConfigParser 77 from configparser import RawConfigParser
78 from io import TextIOWrapper 78 from io import TextIOWrapper
79 except ImportError: 79 except ImportError:
80 from ConfigParser import RawConfigParser # __IGNORE_WARNING__ 80 from ConfigParser import RawConfigParser # __IGNORE_WARNING__
81 81
82 __version__ = '2.1.0' 82 __version__ = '2.1.0-eric'
83 83
84 DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox' 84 DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox'
85 DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503' 85 DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503'
86 try: 86 try:
87 if sys.platform == 'win32': 87 if sys.platform == 'win32':
282 if previous_logical.startswith('@'): 282 if previous_logical.startswith('@'):
283 if blank_lines: 283 if blank_lines:
284 yield 0, "E304 blank lines found after function decorator" 284 yield 0, "E304 blank lines found after function decorator"
285 elif blank_lines > 2 or (indent_level and blank_lines == 2): 285 elif blank_lines > 2 or (indent_level and blank_lines == 2):
286 yield 0, "E303 too many blank lines (%d)", blank_lines 286 yield 0, "E303 too many blank lines (%d)", blank_lines
287 elif logical_line.startswith(('def ', 'async def', 'class ', '@')): 287 elif logical_line.startswith(('def ', 'async def ', 'class ', '@')):
288 if indent_level: 288 if indent_level:
289 if not (blank_before or previous_indent_level < indent_level or 289 if not (blank_before or previous_indent_level < indent_level or
290 DOCSTRING_REGEX.match(previous_logical)): 290 DOCSTRING_REGEX.match(previous_logical)):
291 ancestor_level = indent_level 291 ancestor_level = indent_level
292 nested = False 292 nested = False
989 E701: finally: cleanup() 989 E701: finally: cleanup()
990 E701: if foo == 'blah': one(); two(); three() 990 E701: if foo == 'blah': one(); two(); three()
991 E702: do_one(); do_two(); do_three() 991 E702: do_one(); do_two(); do_three()
992 E703: do_four(); # useless semicolon 992 E703: do_four(); # useless semicolon
993 E704: def f(x): return 2*x 993 E704: def f(x): return 2*x
994 E705: async def f(x): return 2*x
994 E731: f = lambda x: 2*x 995 E731: f = lambda x: 2*x
995 """ 996 """
996 line = logical_line 997 line = logical_line
997 last_char = len(line) - 1 998 last_char = len(line) - 1
998 found = line.find(':') 999 found = line.find(':')
1010 yield 0, ("E731 do not assign a lambda expression, use a " 1011 yield 0, ("E731 do not assign a lambda expression, use a "
1011 "def") 1012 "def")
1012 break 1013 break
1013 if line.startswith('def '): 1014 if line.startswith('def '):
1014 yield 0, "E704 multiple statements on one line (def)" 1015 yield 0, "E704 multiple statements on one line (def)"
1016 elif line.startswith('async def '):
1017 yield 0, "E705 multiple statements on one line (async def)"
1015 else: 1018 else:
1016 yield found, "E701 multiple statements on one line (colon)" 1019 yield found, "E701 multiple statements on one line (colon)"
1017 prev_found = found 1020 prev_found = found
1018 found = line.find(':', found + 1) 1021 found = line.find(':', found + 1)
1019 found = line.find(';') 1022 found = line.find(';')

eric ide

mercurial