Different results running Black formatter standalone vs. from PyDev

163 Views Asked by At

When I run Black formatter (configured as a path to the executable) on file save in PyDev it inserts empty lines around functions, but when I run the same executable from command line it does not. Both invocations are using the same pyproject.toml file. Any ideas why this can be happening?

EDIT: the file in question is a .pyi file

1

There are 1 best solutions below

0
VladG On

I think I know what's happening. Black uses different rules for formatting .pyi files, I peeked inside PyDev and it looks like it runs Black on a temp file, so I think what's happening is that it loses the pyi extension and Black treats the temp file as a normal py file. VSCode had a similar issue: https://github.com/microsoft/vscode-python/issues/13341

Seems like a PyDev bug.