Skip to content

strange wrapping with long PEP 695 type and long signature #4723

@asottile-sentry

Description

@asottile-sentry

Describe the bug

I expect the wrapping to look nicer

To Reproduce

For example, take this code:

class Example:
    @overload
    @classmethod
    def create_from[TBool: (Literal[True], Literal[False])](
        cls: type[SearchConfig[Any]],
        search_config: SearchConfig[Any],
        *,
        allow_boolean: TBool,
        **overrides: Any,
    ) -> SearchConfig[TBool]: ...

And run it with these arguments:

$ black t.py --target-version py313 --line-length 100

and the result is:

class Example:
    @overload
    @classmethod
    def create_from[TBool: (
        Literal[True],
        Literal[False],
    )](
        cls: type[SearchConfig[Any]],
        search_config: SearchConfig[Any],
        *,
        allow_boolean: TBool,
        **overrides: Any,
    ) -> SearchConfig[TBool]: ...

Expected behavior

(no change ideally?)

there's two weirdnesses

  • the typevar was already pretty short so it should not have been wrapped
  • the wrapping feels wrong -- it doesn't follow black's usual parameter indentation

Environment

  • Black's version: 25.1.0
  • OS and Python version: macos 3.13.1

Additional context

nope!

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions