From 4d44c84431b9b83080f0eaea4ba429fd1b6b8ea8 Mon Sep 17 00:00:00 2001 From: Bryan Bugyi Date: Sun, 10 Nov 2019 18:27:10 -0500 Subject: [PATCH] [fix] Recognize '# noqa' as an inline pragma --- black.py | 4 ++-- tests/data/cantfit.py | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/black.py b/black.py index 9b087245f05..669520ef35b 100644 --- a/black.py +++ b/black.py @@ -310,7 +310,7 @@ def target_version_option_callback( is_flag=True, help=( "Don't write the files back, just return the status. Return code 0 means " - "nothing would change. Return code 1 means some files would be reformatted. " + "nothing would change. Return code 1 means some files would be reformatted. " "Return code 123 means there was an internal error." ), ) @@ -2491,7 +2491,7 @@ def validate_string(str_idx: int) -> None: raise CannotSplit("This split function does not work on multiline strings.") if line.comments and re.match( - "^# [A-Za-z_0-9]+: .*$", list(line.comments.values())[0][0].value + "^# ([A-Za-z_0-9]+: .*|noqa)$", list(line.comments.values())[0][0].value ): raise CannotSplit( "Line appears to end with an inline pragma comment. Splitting the line " diff --git a/tests/data/cantfit.py b/tests/data/cantfit.py index 83f87297e94..4030808faeb 100644 --- a/tests/data/cantfit.py +++ b/tests/data/cantfit.py @@ -85,10 +85,7 @@ ), this_is_a_ridiculously_long_name_and_nobody_in_their_right_mind_would_use_one_like_it=0, ) -string_variable_name = ( - "a string that is waaaaaaaayyyyyyyy too long, even in parens, there's nothing you " - "can do" -) # noqa +string_variable_name = "a string that is waaaaaaaayyyyyyyy too long, even in parens, there's nothing you can do" # noqa for key in """ hostname port