推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
mimzy
V2EX  ›  Python

代码格式化工具 Black 发布首个稳定版

  •  
  •   mimzy ·
    mookrs · Feb 9, 2022 · 4105 views
    This topic created in 1697 days ago, the information mentioned may be changed or developed.
    https://github.com/psf/black/releases/tag/22.1.0

    10 天前发布的,终于不 beta 了。我应该是从 19.x 开始用的,配合 isort 再也没操心过格式化问题。
    5 replies  •  2022-02-13 23:57:17 +08:00
    daiqiangbudainiu
        1
    daiqiangbudainiu  
       Feb 9, 2022
    我也在用,但是其他人觉得他格式化的规则有些东西不太能接受
    weakish
        2
    weakish  
       Feb 10, 2022
    一直在用。但是稳定版「 Remove Python 2 support 」, 糟糕,看来要换工具了,头疼。
    mimzy
        3
    mimzy  
    OP
       Feb 10, 2022 via Android
    @weakish 继续用 Black 老版本问题不大。另外如果不是特别难迁移的项目 还是升级吧…连 3.6 都 end of life 了
    ClericPy
        4
    ClericPy  
       Feb 13, 2022
    现在还是不支持 format selection... 等了多少年了, 一点放开口子的趋势都不给, 给个 --lines 参数也行

    有时候我要给别人代码提 commit, 我不能因为改一行代码格式化一两万行别人代码啊. 至于说拉出来单独格式化或者用 darker... 算了
    yucongo
        5
    yucongo  
       Feb 13, 2022
    # fmt:off
    ...
    # fmt: on
    可以临时关掉 black 。以前 black 和 pylint 在多行定义函数时有冲突我常用这个。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   941 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 23:40 · PVG 07:40 · LAX 16:40 · JFK 19:40
    ♥ Do have faith in what you're doing.