diff options
author | Bryce Guinta <bryce.guinta@protonmail.com> | 2018-07-02 09:18:11 -0600 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-07-02 10:18:11 -0500 |
commit | 9c1812b712481bd3cf7340dbd4781b8f7d0e1d3d (patch) | |
tree | 06cfbca09ad8b80253e915494aac7bfcc81f1901 | |
parent | 07aad4930fcf1f6683c0f467f20eef29966c10c5 (diff) | |
download | pylint-git-9c1812b712481bd3cf7340dbd4781b8f7d0e1d3d.tar.gz |
Acknowledge that ellipses are allowed in typing annotations (#2236)
Prevents false-positive bad-whitespace message
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/whatsnew/2.0.rst | 3 | ||||
-rw-r--r-- | pylint/checkers/format.py | 2 | ||||
-rw-r--r-- | pylint/test/unittest_checker_format.py | 7 |
4 files changed, 16 insertions, 1 deletions
@@ -352,6 +352,11 @@ Release date: |TBA| Close #2022 + * Fix false-positive ``bad-whitespace`` message for typing annoatations + with ellipses in them + + Close 1992 + What's New in Pylint 1.9? ========================= diff --git a/doc/whatsnew/2.0.rst b/doc/whatsnew/2.0.rst index 0128f19e1..fb9ea9154 100644 --- a/doc/whatsnew/2.0.rst +++ b/doc/whatsnew/2.0.rst @@ -330,5 +330,8 @@ Other Changes this might actually cause bugs, so if you want to check for ``None`` values as well, pass ``--ignore-none=n`` to pylint. +* Fix false-positive ``bad-whitespace`` message for typing annoatations + with ellipses in them + .. _PEP 563: https://www.python.org/dev/peps/pep-0563/ diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py index c5ecf1611..6e644dc7e 100644 --- a/pylint/checkers/format.py +++ b/pylint/checkers/format.py @@ -682,7 +682,7 @@ class FormatChecker(BaseTokenChecker): elif token[1] == ',': if not bracket_level: return False - elif token[1] == '.': + elif token[1] in ('.', '...'): continue elif token[0] not in (tokenize.NAME, tokenize.STRING, tokenize.NL): return False diff --git a/pylint/test/unittest_checker_format.py b/pylint/test/unittest_checker_format.py index ae037308f..97e3a35a6 100644 --- a/pylint/test/unittest_checker_format.py +++ b/pylint/test/unittest_checker_format.py @@ -331,6 +331,13 @@ class TestCheckSpace(CheckerTestCase): args=('Exactly one', 'required', 'around', 'comparison', 'a< b\n ^'))): self.checker.process_tokens(_tokenize_str('a< b\n')) + def testValidTypingAnnotationEllipses(self): + """Make sure ellipses in function typing annotation + doesn't cause a false positive bad-whitespace message""" + with self.assertNoMessages(): + self.checker.process_tokens( + _tokenize_str('def foo(t: Tuple[str, ...] = None):\n')) + def testEmptyLines(self): self.checker.config.no_space_check = [] with self.assertAddsMessages( |