Skip to content

(🐞) blackd bad f-string fragment causes 500 response #3616

@KotlinIsland

Description

@KotlinIsland

Describe the bug

Blackd is inconsistent with black in regards to formatting invalid f-strings. While black returns a consistent error code of '123' for , and f"{}", blackd returns an expected 400 for the former, but a surprising 500 for the later.

To Reproduce

👉 curl -XPOST "localhost:9090" -d "," -i
400: bad request, take it away

Cannot parse: 1:0: , 
👉 curl -XPOST "localhost:9090" -d 'f"{}"' -i
500: internal server error

cannot use --safe with this file; failed to parse source file AST: f-string: empty expression not allowed (<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. 

Environment

  • Black's version: 23.1.0
  • OS and Python version: windows / python 3.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working
    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