#3685·black

Black is wrapping type hints with arguments when using multi-line string literals

Author: tunecrewCreated May 10, 2023Updated Sep 29, 2026
LabelsT: bug

Describe the bug

Black is wrapping some type hints when using multi-line string literals.

Any type hint with an argument seems to trigger this.

A bare type hint, e.g. str does not trigger this.

To Reproduce

For example, take this code:

python
from typing import Final

query: Final[str] = """
  SELECT my_column
  FROM my_table
  WHERE my_column > 1;
"""

And run it with these arguments:

bash
$ black file.py --target-version py311

The resulting error is:

python
from typing import Final

query: Final[
str
] = """
  SELECT my_column
  FROM my_table
  WHERE my_column > 1;
"""

Expected behavior

I expect no formatting changes to occur

Environment

  • Black's version: 23.3.0
  • OS and Python version: macOS 13.3.1 (a) / python 3.11.3