eric6/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py

changeset 8243
cc717c2ae956
parent 8234
fcb6b4b96274
child 8273
698ae46f40a4
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
10 import queue 10 import queue
11 import ast 11 import ast
12 import re 12 import re
13 import traceback 13 import traceback
14 import multiprocessing 14 import multiprocessing
15 15 import contextlib
16 16
17 try: 17 with contextlib.suppress(ImportError):
18 from pyflakes.checker import Checker 18 from pyflakes.checker import Checker
19 from pyflakes.messages import ImportStarUsed, ImportStarUsage 19 from pyflakes.messages import ImportStarUsed, ImportStarUsage
20 except ImportError:
21 pass
22 20
23 VcsConflictMarkerRegExpList = ( 21 VcsConflictMarkerRegExpList = (
24 re.compile( 22 re.compile(
25 r"""^<<<<<<< .*?\|\|\|\|\|\|\| .*?=======.*?>>>>>>> .*?$""", 23 r"""^<<<<<<< .*?\|\|\|\|\|\|\| .*?=======.*?>>>>>>> .*?$""",
26 re.MULTILINE | re.DOTALL 24 re.MULTILINE | re.DOTALL
281 fn = filename 279 fn = filename
282 line = 1 280 line = 1
283 error = str(detail) 281 error = str(detail)
284 return [{'error': (fn, line, 0, "", error)}] 282 return [{'error': (fn, line, 0, "", error)}]
285 except Exception as detail: 283 except Exception as detail:
286 try: 284 with contextlib.suppress(Exception):
287 fn = detail.filename 285 fn = detail.filename
288 line = detail.lineno 286 line = detail.lineno
289 error = detail.msg 287 error = detail.msg
290 return [{'error': (fn, line, 0, "", error)}] 288 return [{'error': (fn, line, 0, "", error)}]
291 except Exception: # secok
292 pass
293 289
294 # pyflakes 290 # pyflakes
295 if not checkFlakes: 291 if not checkFlakes:
296 return [{}] 292 return [{}]
297 293
307 ): 303 ):
308 continue 304 continue
309 305
310 _fn, lineno, col, message, msg_args = warning.getMessageData() 306 _fn, lineno, col, message, msg_args = warning.getMessageData()
311 lineFlags = extractLineFlags(lines[lineno - 1].strip()) 307 lineFlags = extractLineFlags(lines[lineno - 1].strip())
312 try: 308 with contextlib.suppress(IndexError):
313 lineFlags += extractLineFlags(lines[lineno].strip(), 309 lineFlags += extractLineFlags(lines[lineno].strip(),
314 flagsLine=True) 310 flagsLine=True)
315 except IndexError:
316 pass
317 if ( 311 if (
318 "__IGNORE_WARNING__" not in lineFlags and 312 "__IGNORE_WARNING__" not in lineFlags and
319 "noqa" not in lineFlags 313 "noqa" not in lineFlags
320 ): 314 ):
321 results.append((_fn, lineno, col, "", message, msg_args)) 315 results.append((_fn, lineno, col, "", message, msg_args))

eric ide

mercurial