diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-05-20 09:48:48 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-05-20 09:48:48 +0200 |
commit | 44248e9f67cd066111af139113670f5c315de890 (patch) | |
tree | f5a4f4ffb34d814a1fe9a7cac220f81b06e597be | |
parent | 2c403bbf00a52a7821a7e19cfae1f9c4f092d7da (diff) | |
download | pylint-git-44248e9f67cd066111af139113670f5c315de890.tar.gz |
Syntax errors report the column number.
Close #2914
-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", |