導(dǎo)讀 | YAPF 0.17.0 已發(fā)布,YAPF 是 Google 開源的一個(gè)用來格式化 Python 代碼的工具。 |
目前用于 Python 的格式化程序(如 autopep8 和 pep8ify)都用于刪除代碼中的 lint 錯(cuò)誤。這有很明顯的局限性。YAPF 采用了不同的方法,基于 Daniel Jasper 開發(fā)的 “clang-format” 。從本質(zhì)上來說,該算法取走代碼并重新排版,以符合樣式指南的最佳格式,即便原始代碼沒有違反樣式指南。這個(gè)想法也是類似于 Go 編程語言的 gofmt 工具。其最終目標(biāo)是讓 YAPE 所產(chǎn)生的代碼可以與程序員所寫的代碼一樣好(前提是程序員遵循樣式指南),它取代了一些維護(hù)代碼的苦差。
更新內(nèi)容:
新增
- Option `NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS` prevents adding spaces around selected binary operators, in accordance with the current style guide.
更改
- Adjust blank lines on formatting boundaries when using the `--lines` option.
- Return 1 if a diff changed the code. This is in line with how GNU diff acts.
修復(fù)
- Corrected how `DEDENT_CLOSING_BRACKETS` and `COALESCE_BRACKETS` interacted.
- Fix return value to return a boolean.
- Correct vim plugin not to clobber edited code if yapf returns an error.
- Ensured comma-terminated tuples with multiple elements are split onto separate lines.
下載地址:文章來源:http://www.zghlxwxcb.cn/news/detail-743385.html
- Source code?(zip)
- Source code?(tar.gz)
相關(guān)鏈接文章來源地址http://www.zghlxwxcb.cn/news/detail-743385.html
- YAPF 的詳細(xì)介紹:點(diǎn)擊查看
- YAPF 的下載地址:點(diǎn)擊下載
到了這里,關(guān)于Python 代碼格式化工具YAPF 0.17.0問世的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!