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 tkinter三种布局实例详解

    Python tkinter三种布局实例详解

    这篇文章主要介绍了Python tkinter三种布局实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-01-01
  • Python类的继承与多态详细介绍

    Python类的继承与多态详细介绍

    大家好,本篇文章主要讲的是Python类的继承与多态详细介绍,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下,方便下次浏览
    2022-01-01
  • pytorch 实现打印模型的参数值

    pytorch 实现打印模型的参数值

    今天小编就为大家分享一篇pytorch 实现打印模型的参数值,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-12-12
  • python中二分查找法的实现方法

    python中二分查找法的实现方法

    在本篇内容里小编给大家整理了关于python中二分查找法的实现方法,有需要的朋友们可以学习下。
    2020-12-12
  • python 爬虫百度地图的信息界面的实现方法

    python 爬虫百度地图的信息界面的实现方法

    这篇文章主要介绍了python 爬虫百度地图的界面的实现方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-10-10
  • 详解python中__name__的意义以及作用

    详解python中__name__的意义以及作用

    这篇文章主要介绍了详解python中__name__的意义以及作用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-08-08
  • Python 中面向接口编程详情

    Python 中面向接口编程详情

    这篇文章主要介绍了Python 中面向接口编程详情,Python 中的接口与大多数其它语言的处理方式不同,它们的设计复杂性也不同,关于Python 接口编程的介绍,需要的小伙伴可以参考下面文章内容
    2022-05-05
  • Python生成可执行文件之PyInstaller库的使用方式

    Python生成可执行文件之PyInstaller库的使用方式

    PyInstaller是一个十分有用的第三方库,通过对源文件打包,Python程序可以在没有安装Python的环境中运行,也可以作为一个独立文件方便传递和管理,下面这篇文章主要给大家介绍了关于Python生成可执行文件之PyInstaller库的使用方式,需要的朋友可以参考下
    2022-04-04
  • python向MySQL数据库插入数据的操作方法

    python向MySQL数据库插入数据的操作方法

    这篇文章主要介绍了python向MySQL数据库插入数据,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-11-11
  • python实现一个摇骰子小游戏

    python实现一个摇骰子小游戏

    大家好,本篇文章主要讲的是python实现一个摇骰子小游戏,感兴趣的同学赶快来看一看吧,对你有帮助的话记得收藏一下
    2022-01-01

最新评论