【问题标题】:The Black formatter - how to scan only chosen directories黑色格式化程序 - 如何仅扫描选定的目录
【发布时间】:2021-08-09 10:47:29
【问题描述】:

我想在 jenkins 共享库中实现黑色扫描仪。这个想法是,当库看到pyproject.toml 时,它将执行黑色检查。该命令设置为 black --check ./ 。这将为所有项目设置一次,因此应尽可能通用(为所有文件设置检查)。

如何设置pyproject.toml 使其只能扫描选定的目录?

我试图排除所有内容,只包含我想要的内容。但这不起作用。我的正则表达式很弱。

[tool.black]
exclude = '''
/(
  | *
)/

'''
include = '''
/(
  | pytest/**
)/

'''

【问题讨论】:

    标签: python jenkins-pipeline


    【解决方案1】:

    我自己找到了答案。就……

    [tool.black]
    include = 'pytest\/.*\.pyi?$'
    

    ...或多个目录...

    [tool.black]
    include = 'pytest\/.*\.pyi?$|tests\/subdirectory\/.*\.pyi?$'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-05
      • 2018-03-27
      • 1970-01-01
      • 1970-01-01
      • 2020-02-23
      • 1970-01-01
      相关资源
      最近更新 更多