diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | pylint/lint.py | 8 | ||||
-rw-r--r-- | pylint/test/test_self.py | 2 |
3 files changed, 10 insertions, 4 deletions
@@ -7,6 +7,10 @@ What's New in Pylint 2.4.0? Release date: TBA +* Syntax errors report the column number. + + Close #2914 + * Support fully qualified typing imports for type annotations. Close #2915 diff --git a/pylint/lint.py b/pylint/lint.py index 809e2294b..f1ebd1a1e 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -66,6 +66,7 @@ import operator import os import sys import tokenize +import traceback import warnings from io import TextIOWrapper @@ -1176,13 +1177,14 @@ class PyLinter( except astroid.AstroidSyntaxError as ex: # pylint: disable=no-member self.add_message( - "syntax-error", line=getattr(ex.error, "lineno", 0), args=str(ex.error) + "syntax-error", + line=getattr(ex.error, "lineno", 0), + col_offset=getattr(ex.error, "offset", None), + args=str(ex.error), ) except astroid.AstroidBuildingException as ex: self.add_message("parse-error", args=ex) except Exception as ex: - import traceback - traceback.print_exc() self.add_message("astroid-error", args=(ex.__class__, ex)) diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py index b5000f98e..8fe3efe20 100644 --- a/pylint/test/test_self.py +++ b/pylint/test/test_self.py @@ -401,7 +401,7 @@ class TestRunTC(object): assert isinstance(output[0], dict) expected = { "obj": "", - "column": 0, + "column": 15, "line": 1, "type": "error", "symbol": "syntax-error", |