Skip to content

Commit

Permalink
Leave non breaking space in comment with 'type: ignore' inside
Browse files Browse the repository at this point in the history
The switch to unvalid 'type: ignore' to valid 'type: ignore' is a
lot more complicated to do.

See:psf#2092
  • Loading branch information
Pierre-Sassoulas committed Apr 11, 2021
1 parent 92438c8 commit 6714ec1
Showing 1 changed file with 3 additions and 2 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 = " " + content[1:] # Replace NBSP by a simple space
if content and content[0] not in " !:#'%":
content = " " + content
return "#" + content
Expand Down

0 comments on commit 6714ec1

Please sign in to comment.