ruff check文件目录检测--exclude参数设置路径详解

 更新时间:2023年10月29日 10:17:25   作者:ponponon  
这篇文章主要为大家介绍了ruff check文件目录检测exclude参数如何设置多少路径详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

ruff check --help

Run Ruff on the given files or directories (default)

Usage: ruff check [OPTIONS] [FILES]...

Arguments:
  [FILES]...  List of files or directories to check

Options:
      --fix
          Apply fixes to resolve lint violations. Use `--no-fix` to disable or `--unsafe-fixes` to include unsafe fixes
      --unsafe-fixes
          Include fixes that may not retain the original intent of the code. Use `--no-unsafe-fixes` to disable
      --show-source
          Show violations with source code. Use `--no-show-source` to disable
      --show-fixes
          Show an enumeration of all fixed lint violations. Use `--no-show-fixes` to disable
      --diff
          Avoid writing any fixed files back; instead, output a diff for each changed file to stdout. Implies `--fix-only`
  -w, --watch
          Run in watch mode by re-running whenever files change
      --fix-only
          Apply fixes to resolve lint violations, but don't report on leftover violations. Implies `--fix`. Use `--no-fix-only` to disable or `--unsafe-fixes` to include unsafe fixes
      --ignore-noqa
          Ignore any `# noqa` comments
      --output-format <OUTPUT_FORMAT>
          Output serialization format for violations [env: RUFF_OUTPUT_FORMAT=] [possible values: text, json, json-lines, junit, grouped, github, gitlab, pylint, azure]
  -o, --output-file <OUTPUT_FILE>
          Specify file to write the linter output to (default: stdout)
      --target-version <TARGET_VERSION>
          The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312]
      --preview
          Enable preview mode; checks will include unstable rules and fixes. Use `--no-preview` to disable
      --config <CONFIG>
          Path to the `pyproject.toml` or `ruff.toml` file to use for configuration
      --statistics
          Show counts for every rule with at least one violation
      --add-noqa
          Enable automatic additions of `noqa` directives to failing lines
      --show-files
          See the files Ruff will be run against with the current settings
      --show-settings
          See the settings Ruff will use to lint a given Python file
  -h, --help
          Print help

Rule selection:
      --select <RULE_CODE>
          Comma-separated list of rule codes to enable (or ALL, to enable all rules)
      --ignore <RULE_CODE>
          Comma-separated list of rule codes to disable
      --extend-select <RULE_CODE>
          Like --select, but adds additional rule codes on top of those already specified
      --per-file-ignores <PER_FILE_IGNORES>
          List of mappings from file pattern to code to exclude
      --extend-per-file-ignores <EXTEND_PER_FILE_IGNORES>
          Like `--per-file-ignores`, but adds additional ignores on top of those already specified
      --fixable <RULE_CODE>
          List of rule codes to treat as eligible for fix. Only applicable when fix itself is enabled (e.g., via `--fix`)
      --unfixable <RULE_CODE>
          List of rule codes to treat as ineligible for fix. Only applicable when fix itself is enabled (e.g., via `--fix`)
      --extend-fixable <RULE_CODE>
          Like --fixable, but adds additional rule codes on top of those already specified

File selection:
      --exclude <FILE_PATTERN>         List of paths, used to omit files and/or directories from analysis
      --extend-exclude <FILE_PATTERN>  Like --exclude, but adds additional files and directories on top of those already excluded
      --respect-gitignore              Respect file exclusions via `.gitignore` and other standard ignore files. Use `--no-respect-gitignore` to disable
      --force-exclude                  Enforce exclusions, even for paths passed to Ruff directly on the command-line. Use `--no-force-exclude` to disable

Miscellaneous:
  -n, --no-cache
          Disable cache reads
      --isolated
          Ignore all configuration files
      --cache-dir <CACHE_DIR>
          Path to the cache directory [env: RUFF_CACHE_DIR=]
      --stdin-filename <STDIN_FILENAME>
          The name of the file when passing it through stdin
  -e, --exit-zero
          Exit with status code "0", even upon detecting lint violations
      --exit-non-zero-on-fix
          Exit with a non-zero status code if any files were modified via fix, even if no lint violations remain

Log levels:
  -v, --verbose  Enable verbose logging
  -q, --quiet    Print diagnostics, but nothing else
  -s, --silent   Disable all logging (but still exit with status code "1" upon detecting diagnostics)

主要部分

File selection:
      --exclude <FILE_PATTERN>         List of paths, used to omit files and/or directories from analysis
      --extend-exclude <FILE_PATTERN>  Like --exclude, but adds additional files and directories on top of those already excluded
      --respect-gitignore              Respect file exclusions via `.gitignore` and other standard ignore files. Use `--no-respect-gitignore` to disable
      --force-exclude                  Enforce exclusions, even for paths passed to Ruff directly on the command-line. Use `--no-force-exclude` to disable

错误做法

ruff check . --exclude testing,dev
ruff check . --exclude testing;dev

正确做法

使用 --extend-exclude 追加

ruff check . --exclude testing --extend-exclude dev

如果有更多目录呢?无限追加 --extend-exclude 就好了

ruff check . --exclude testing --extend-exclude dev --extend-exclude core

以上就是ruff check文件目录检测--exclude参数设置路径详解的详细内容,更多关于ruff check exclude参数设置路径的资料请关注脚本之家其它相关文章!

相关文章

  • Python使用psutil库实现系统监控与管理详解

    Python使用psutil库实现系统监控与管理详解

    在我们的测试工作中,监控和管理系统资源是一项重要的任务,本文将介绍如何使用psutil库来实现系统监控和管理,以及一些实用的技巧和示例,希望对大家有所帮助
    2022-10-10
  • Python写代码的七条重要技巧介绍

    Python写代码的七条重要技巧介绍

    大家好,本篇文章主要讲的是Python写代码的七条重要技巧介绍,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下,方便下次浏览
    2021-12-12
  • 使用Python做一个文档转化器的代码实现

    使用Python做一个文档转化器的代码实现

    Python 文档转换器项目旨在通过 Python 技术实现多种文档格式之间的自动化转换,解决不同格式文件在跨平台、跨应用场景下的兼容性问题,本文给大家介绍了如何使用Python做一个文档转化器,需要的朋友可以参考下
    2026-02-02
  • python实现名片管理系统

    python实现名片管理系统

    这篇文章主要为大家详细介绍了python实现名片管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-11-11
  • numpy工程实践之np.savetxt()存储数据

    numpy工程实践之np.savetxt()存储数据

    NumPy提供了多种存取数组内容的文件操作函数,保存数组数据的文件可以是二进制格式或者文本格式,下面这篇文章主要给大家介绍了关于numpy工程实践之np.savetxt()存储数据的相关资料,需要的朋友可以参考下
    2023-05-05
  • python十进制转二进制的详解

    python十进制转二进制的详解

    在本篇文章里小编给大家整理了关于python十进制转二进制的相关知识点内容,需要的朋友们可以参考学习下。
    2020-02-02
  • Python读写docx文件的方法

    Python读写docx文件的方法

    今天小编就为大家分享一篇Python读写docx文件的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-05-05
  • PyTorch实现线性回归详细过程

    PyTorch实现线性回归详细过程

    本文介绍PyTorch实现线性回归,线性关系是一种非常简单的变量之间的关系,因变量和自变量在线性关系的情况下,可以使用线性回归算法对一个或多个因变量和自变量间的线性关系进行建模,该模型的系数可以用最小二乘法进行求解,需要的朋友可以参考一下
    2022-03-03
  • 解决plt.savefig()和plt.show()方法得到的图片不一样问题

    解决plt.savefig()和plt.show()方法得到的图片不一样问题

    这篇文章主要介绍了解决plt.savefig()和plt.show()方法得到的图片不一样问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2023-08-08
  • 教你用python控制安卓手机

    教你用python控制安卓手机

    不久前,我在思考如何通过向好友发送几分钟的垃圾邮件来惹恼我的朋友,而在做一些研究的过程中,我遇到了Android调试桥.在本快速指南中,我将向您展示如何使用Python与之交互以及如何创建2个快速脚本.需要的朋友可以参考下
    2021-05-05

最新评论