不同于单独运行Black格式化程序和从PyDev运行时的结果。

huangapple go评论50阅读模式
英文:

Different results running Black formatter standalone vs. from PyDev

问题

当我在PyDev中以可执行文件路径配置运行Black格式化程序(在保存文件时),它会在函数周围插入空行,但当我从命令行运行相同的可执行文件时,它不会这样做。两种调用都使用相同的pyproject.toml文件。有任何想法为什么会发生这种情况吗?

编辑:问题中的文件是一个.pyi文件。

英文:

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

得分: 1

我认为我知道发生了什么。Black使用不同的规则来格式化.pyi文件,我窥探了PyDev,并且看起来它在临时文件上运行Black,所以我认为发生的情况是它丢失了pyi扩展名,而Black将临时文件视为普通的py文件。VSCode曾经有过类似的问题:https://github.com/microsoft/vscode-python/issues/13341

看起来是PyDev的一个bug。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月16日 02:46:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76484659.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定