-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.F: stringsRelated to our handling of stringsRelated to our handling of stringsT: bugSomething isn't workingSomething isn't working
Description
Describe the bug
Black's --preview mode makes it impossible to suppress a type error in a string with a long comment.
To Reproduce
For example, take this code:
def __str__(self):
return "foo bar baz qux" # pyright: ignore[reportGeneralTypeIssues] -- This is some special Django magic that we can't easily tell Pyright aboutAnd run it with these arguments:
$ black --previewThe resulting error is:
Unnecessary "# pyright: ignore" rule: "reportGeneralTypeIssues" (Pylance)
def __str__(self):
return ( # pyright: ignore[reportGeneralTypeIssues] -- This is some special Django magic that we can't easily tell Pyright about
"foo bar baz qux"
)If I move the comment to the middle line, black moves it back up to the top.
Expected behavior
Even if black breaks my comment in some cases, there should be at least one possible place for me to leave the comment that will suppress my type error without black moving it.
Environment
- Black's version:
23.7.0 - OS and Python version: MacOS, 3.11
Additional context
This also occurs if the comment starts on the line with the violation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.F: stringsRelated to our handling of stringsRelated to our handling of stringsT: bugSomething isn't workingSomething isn't working