Skip to content

Commit

Permalink
[fix] Recognize '# noqa' as an inline pragma
Browse files Browse the repository at this point in the history
  • Loading branch information
bbugyi200 committed Nov 10, 2019
1 parent d4d1e1f commit 4d44c84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions black.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
),
)
Expand Down Expand Up @@ -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 "
Expand Down
5 changes: 1 addition & 4 deletions tests/data/cantfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d44c84

Please sign in to comment.