Skip to content

Commit

Permalink
Leave non breaking space in 'type: ignore' to be safe
Browse files Browse the repository at this point in the history
See rational:psf#2092
  • Loading branch information
Pierre-Sassoulas committed Apr 11, 2021
1 parent 145d46e commit 3b7b0b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/black/__init__.py
Expand Up @@ -2709,8 +2709,9 @@ def make_comment(content: str) -> str:

if content[0] == "#":
content = content[1:]
if content and content[0] == " ": # This is a non-breaking space
content = " " + content[1:] # And this is a simple space
NON_BREAKING_SPACE = " "
if content and content[0] == NON_BREAKING_SPACE and "type: ignore" not in content:
content[0] = " " # Replace NBSP by a simple space
if content and content[0] not in " !:#'%":
content = " " + content
return "#" + content
Expand Down
2 changes: 1 addition & 1 deletion tests/data/comments7.py
Expand Up @@ -183,7 +183,7 @@ def func():
0.0789,
0.0123,
0.0789,
a[-1], # type: ignore
a[-1], # type: ignore
)
c = call(0.0123, 0.0456, 0.0789, 0.0123, 0.0789, a[-1]) # type: ignore
c = call(
Expand Down

0 comments on commit 3b7b0b7

Please sign in to comment.