summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--pylint/checkers/refactoring.py2
-rw-r--r--tests/functional/t/trailing_comma_tuple.py14
-rw-r--r--tests/functional/t/trailing_comma_tuple.txt2
4 files changed, 18 insertions, 2 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 070e50fc9..cd15199a8 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -377,3 +377,5 @@ contributors:
* Slavfox: contributor
* Matthew Beckers (mattlbeck): contributor
+
+* Yang Yang: contributor
diff --git a/pylint/checkers/refactoring.py b/pylint/checkers/refactoring.py
index 75a31c7e6..5293097eb 100644
--- a/pylint/checkers/refactoring.py
+++ b/pylint/checkers/refactoring.py
@@ -95,7 +95,7 @@ def _is_trailing_comma(tokens, index):
"""Get the index denoting the start of the current line"""
for subindex, token in enumerate(reversed(tokens[:index])):
# See Lib/tokenize.py and Lib/token.py in cpython for more info
- if token.type in (tokenize.NEWLINE, tokenize.NL):
+ if token.type == tokenize.NEWLINE:
return index - subindex
return 0
diff --git a/tests/functional/t/trailing_comma_tuple.py b/tests/functional/t/trailing_comma_tuple.py
index a832ccc28..322317030 100644
--- a/tests/functional/t/trailing_comma_tuple.py
+++ b/tests/functional/t/trailing_comma_tuple.py
@@ -1,5 +1,5 @@
"""Check trailing comma one element tuples."""
-# pylint: disable=bad-whitespace, missing-docstring
+# pylint: disable=bad-whitespace, missing-docstring, bad-continuation
AAA = 1, # [trailing-comma-tuple]
BBB = "aaaa", # [trailing-comma-tuple]
CCC="aaa", # [trailing-comma-tuple]
@@ -36,3 +36,15 @@ def some_func(first, second):
def some_other_func():
yield 'hello', # [trailing-comma-tuple]
+
+GGG = ["aaa"
+], # [trailing-comma-tuple]
+
+HHH = ["aaa"
+]
+
+III = some_func(0,
+ 0), # [trailing-comma-tuple]
+
+JJJ = some_func(0,
+ 0)
diff --git a/tests/functional/t/trailing_comma_tuple.txt b/tests/functional/t/trailing_comma_tuple.txt
index bdf53a255..cbc6d1a80 100644
--- a/tests/functional/t/trailing_comma_tuple.txt
+++ b/tests/functional/t/trailing_comma_tuple.txt
@@ -5,3 +5,5 @@ trailing-comma-tuple:6::Disallow trailing comma tuple
trailing-comma-tuple:31::Disallow trailing comma tuple
trailing-comma-tuple:34::Disallow trailing comma tuple
trailing-comma-tuple:38::Disallow trailing comma tuple
+trailing-comma-tuple:41::Disallow trailing comma tuple
+trailing-comma-tuple:47::Disallow trailing comma tuple