Skip to content

crash with the wrong number of spaces before a type-comment for a typed-function #3986

@15r10nk

Description

@15r10nk

Black f7174b

Playground link

Options

--line-length=88
--safe

Input

def name_4[**name_0](): # type: ignore
    pass

Output

cannot use --safe with this file; failed to parse source file AST: invalid syntax (<unknown>, line 1)
This could be caused by running Black with an older Python version that does not support new syntax used in your source file.

Expected

black should be able to format the code.
The problem is the number of spaces before the #.
There is no problem with two spaces before # or if --fast is used.

This works:

def name_4[**name_0]():  # type: ignore
    pass

Metadata

Metadata

Assignees

Labels

C: invalid codeBlack destroyed a valid Python fileC: parserHow we parse code. Or fail to parse it.
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions