-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
Describe the bug
When a multiline dict/function call is collapsed into fewer lines by black, it seems to leave stray trailing commas. This does not happen when using --skip-magic-trailing-comma.
To Reproduce
For example, take this code:
def refresh_token(self, device_family, refresh_token, api_key):
return self.orchestration.refresh_token(
data={
"refreshToken": refresh_token,
},
api_key=api_key,
)["extensions"]["sdk"]["token"]And run it with these arguments:
$ black file.py -l 120The resulting output is:
def refresh_token(self, device_family, refresh_token, api_key):
return self.orchestration.refresh_token(data={"refreshToken": refresh_token,}, api_key=api_key,)["extensions"][
"sdk"
]["token"]Expected behavior
The output should look something like this (without the stray trailing commas):
def refresh_token(self, device_family, refresh_token, api_key):
return self.orchestration.refresh_token(data={"refreshToken": refresh_token}, api_key=api_key)["extensions"][
"sdk"
]["token"]Environment
- Black's version: 22.6.0 / main
- OS and Python version: Debian 10, Python 3.10.4
Additional context
Reactions are currently unavailable