Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

- Fix crash when a standalone comment sits between tokens of a comprehension or lambda
(#5144)
- Respect the magic trailing comma in a PEP 695 type parameter list containing a
`*TypeVarTuple` or `**ParamSpec`, which previously collapsed back onto one line
(#5244)
- Fix crash when a comment-only `# fmt: off`/`# fmt: on` block is followed by a `with`
statement after another standalone comment (#5189)
- Fix a crash when splitting `case case if ...` match patterns at very small line
Expand Down
2 changes: 2 additions & 0 deletions src/black/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
syms.trailer, # single argument to call
syms.typedargslist,
syms.varargslist, # lambdas
syms.typevartuple, # star in a PEP 695 type parameter list
syms.paramspec, # double star in a PEP 695 type parameter list
}
UNPACKING_PARENTS: Final = {
syms.atom, # single element of a list or set literal
Expand Down
29 changes: 29 additions & 0 deletions tests/data/cases/type_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def it_gets_worse[WhatIsTheLongestTypeVarNameYouCanThinkOfEnoughToMakeBlackSplit

def magic[Trailing, Comma,](): pass

def magic_starred[T, *Ts, **P,](): pass

class MagicStarred[T, *Ts, **P,]: pass

type MagicStarredAlias[T, *Ts, **P,] = int

def weird_syntax[T: lambda: 42, U: a or b](): pass

def name_3[name_0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if aaaaaaaaaaa else name_3](): pass
Expand Down Expand Up @@ -62,6 +68,29 @@ def magic[
pass


def magic_starred[
T,
*Ts,
**P,
]():
pass


class MagicStarred[
T,
*Ts,
**P,
]:
pass


type MagicStarredAlias[
T,
*Ts,
**P,
] = int


def weird_syntax[T: lambda: 42, U: a or b]():
pass

Expand Down