285 @rtype tuple of (dict, dict, None) or tuple of (None, None, ast.Module) |
286 @rtype tuple of (dict, dict, None) or tuple of (None, None, ast.Module) |
286 """ |
287 """ |
287 src = "".join(source) |
288 src = "".join(source) |
288 |
289 |
289 try: |
290 try: |
290 tree = ast.parse(src, filename, 'exec') |
291 if sys.version_info >= (3, 8): |
|
292 # need the 'type_comments' parameter to include type annotations |
|
293 tree = ast.parse(src, filename, 'exec', type_comments=True) |
|
294 else: |
|
295 tree = ast.parse(src, filename, 'exec') |
291 return None, None, tree |
296 return None, None, tree |
292 except (SyntaxError, TypeError): |
297 except (SyntaxError, TypeError): |
293 exc_type, exc = sys.exc_info()[:2] |
298 exc_type, exc = sys.exc_info()[:2] |
294 if len(exc.args) > 1: |
299 if len(exc.args) > 1: |
295 offset = exc.args[1] |
300 offset = exc.args[1] |
477 }) |
482 }) |
478 |
483 |
479 if source: |
484 if source: |
480 code = error["code"] |
485 code = error["code"] |
481 lineFlags = extractLineFlags(source[lineno - 1].strip()) |
486 lineFlags = extractLineFlags(source[lineno - 1].strip()) |
482 try: |
487 with contextlib.suppress(IndexError): |
483 lineFlags += extractLineFlags(source[lineno].strip(), |
488 lineFlags += extractLineFlags(source[lineno].strip(), |
484 flagsLine=True) |
489 flagsLine=True) |
485 except IndexError: |
|
486 pass |
|
487 |
490 |
488 if securityOk(code, lineFlags): |
491 if securityOk(code, lineFlags): |
489 error["securityOk"] = True |
492 error["securityOk"] = True |
490 |
493 |
491 if ignoreCode(code, lineFlags): |
494 if ignoreCode(code, lineFlags): |