对Jupyter笔记本中的所有代码单元格应用黑色。

black-nb的Python项目详细描述


black-nb logo

永不妥协的代码格式化程序,适用于Jupyter笔记本电脑

Build StatusCode CoverageCode StyleCode Style

black nbblack应用于jupyter笔记本。

大部分代码取自原始的black项目,其行为故意类似。

安装

pip install black-nb

用法

black应用于当前目录下笔记本中的所有代码单元格:

black-nb .

除了重新格式化之外,还要清除单元格输出:

black-nb --clear-output .

检查笔记本是否通过black并且没有输出(文件将保持不变):

black-nb --clear-output --check .

重新格式化*.ipynb下的所有./文件,不包括匹配*/outputs/**/.ipynb_checkpoints/*的路径:

black-nb --exclude '/(outputs|\.ipynb_checkpoints)/' .

命令行选项

black nb不提供许多选项。您可以通过运行black-nb --help

Usage: black-nb [OPTIONS] [SRC]...

  The uncompromising code formatter, for Jupyter notebooks.

Options:
  -l, --line-length INTEGER  How many characters per line to allow.  [default:
                             79]
  --check                    Don't write the files back, just return the
                             status.  Return code 0 means nothing would
                             change.  Return code 1 means some files would be
                             reformatted.  Return code 123 means there was an
                             internal error.
  --include TEXT             A regular expression that matches files and
                             directories that should be included on recursive
                             searches.  An empty value means all files are
                             included regardless of the name.  Use forward
                             slashes for directories on all platforms
                             (Windows, too).  Exclusions are calculated first,
                             inclusions later.  [default: \.ipynb$]
  --exclude TEXT             A regular expression that matches files and
                             directories that should be excluded on recursive
                             searches. An empty value means no paths are
                             excluded. Use forward slashes for directories on
                             all platforms (Windows, too). Exclusions are
                             calculated first, inclusions later.  [default: /(
                             \.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build
                             |buck-out|build|dist|\.ipynb_checkpoints)/]
  -q, --quiet                Don't emit non-error messages to stderr. Errors
                             are still emitted, silence those with
                             2>/dev/null.
  -v, --verbose              Also emit messages to stderr about files that
                             were not changed or were ignored due to
                             --exclude=.
  --clear-output             Clear cell output as part of formatting.
  --config FILE              Read configuration from PATH.
  -h, --help                 Show this message and exit.

版权所有

版权所有©2019 Tom Catling,Liam Coatman。

black-nbMIT licence的条件分布。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将cassandra中的行数据转换为与列相关的嵌套json   java如何使用jcr XPath在jcr:content/@jcr:data中搜索?   java在使用openCV进行安卓开发时如何利用手机的广角镜头   java解析扩展了接口,结束了一个潜在的无限循环   位置服务的@Override方法中存在java Android应用程序错误   java本地线程的用途和需求是什么   具有左右子访问的java节点树遍历   java验证JsonWebToken签名   JUL日志处理程序中的java日志记录   嵌入式Java读取给定时间段的串行数据。   java有没有办法从多个URL获取多个图像?   java线程通过等待intent阻止自己发送intent   java Spring MVC解析多部分内容请求   java JPA/Hibernate静态元模型属性未填充NullPointerException   java格式错误的字符(需要引号,得到I)~正在处理   java为什么PrintWriter对象抛出FileNotFoundException?   java Neo4j未正确保存标签   java IE不加载图像