From: Michael J. Sullivan Date: Thu, 10 Oct 2019 18:50:51 +0000 (-0700) Subject: Fix issue with type comments on lines with trailing commas (#1058) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/6fe800933d8919436cabf40466ee462f49463814?ds=inline Fix issue with type comments on lines with trailing commas (#1058) The code introduced in #1027 to detect whether a type comment appeared after a regular comment in a Line would spuriously misfire when a leaf was in the comments dict but had an empty list of comments. This can occur as an artifact of how comments on trailing commas are handled, it seems. (This was discovered trying to test black out on mypy.) --- diff --git a/black.py b/black.py index f283ffc..d8aa356 100644 --- a/black.py +++ b/black.py @@ -1321,7 +1321,7 @@ class Line: if leaf_id not in ignored_ids or comment_seen: return True - comment_seen = True + comment_seen = True return False diff --git a/tests/data/comments2.py b/tests/data/comments2.py index 54b7b00..248552c 100644 --- a/tests/data/comments2.py +++ b/tests/data/comments2.py @@ -146,6 +146,7 @@ short ], ) +CONFIG_FILES = [CONFIG_FILE, ] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final ####################### ### SECTION COMMENT ### @@ -313,6 +314,8 @@ short ) +CONFIG_FILES = [CONFIG_FILE] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final + ####################### ### SECTION COMMENT ### #######################