<!-- Begin section: Overview -->
# Ruff
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![image](https://img.shields.io/pypi/v/ruff.svg)](https://pypi.python.org/pypi/ruff)
[![image](https://img.shields.io/pypi/l/ruff.svg)](https://pypi.python.org/pypi/ruff)
[![image](https://img.shields.io/pypi/pyversions/ruff.svg)](https://pypi.python.org/pypi/ruff)
[![Actions status](https://github.com/astral-sh/ruff/workflows/CI/badge.svg)](https://github.com/astral-sh/ruff/actions)
[![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord&logoColor=white)](https://discord.com/invite/astral-sh)
[**Docs**](https://docs.astral.sh/ruff/) | [**Playground**](https://play.ruff.rs/)
An extremely fast Python linter and code formatter, written in Rust.
<p align="center">
<picture align="center">
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/1309177/232603514-c95e9b0f-6b31-43de-9a80-9e844173fd6a.svg">
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/1309177/232603516-4fb4892d-585c-4b20-b810-3db9161831e4.svg">
<img alt="Shows a bar chart with benchmark results." src="https://user-images.githubusercontent.com/1309177/232603516-4fb4892d-585c-4b20-b810-3db9161831e4.svg">
</picture>
</p>
<p align="center">
<i>Linting the CPython codebase from scratch.</i>
</p>
- â¡ï¸ 10-100x faster than existing linters (like Flake8) and formatters (like Black)
- ð Installable via `pip`
- ð ï¸ `pyproject.toml` support
- ð¤ Python 3.12 compatibility
- âï¸ Drop-in parity with [Flake8](https://docs.astral.sh/ruff/faq/#how-does-ruff-compare-to-flake8), isort, and Black
- ð¦ Built-in caching, to avoid re-analyzing unchanged files
- ð§ Fix support, for automatic error correction (e.g., automatically remove unused imports)
- ð Over [700 built-in rules](https://docs.astral.sh/ruff/rules/), with native re-implementations
of popular Flake8 plugins, like flake8-bugbear
- â¨ï¸ First-party [editor integrations](https://docs.astral.sh/ruff/integrations/) for
[VS Code](https://github.com/astral-sh/ruff-vscode) and [more](https://github.com/astral-sh/ruff-lsp)
- ð Monorepo-friendly, with [hierarchical and cascading configuration](https://docs.astral.sh/ruff/configuration/#pyprojecttoml-discovery)
Ruff aims to be orders of magnitude faster than alternative tools while integrating more
functionality behind a single, common interface.
Ruff can be used to replace [Flake8](https://pypi.org/project/flake8/) (plus dozens of plugins),
[Black](https://github.com/psf/black), [isort](https://pypi.org/project/isort/),
[pydocstyle](https://pypi.org/project/pydocstyle/), [pyupgrade](https://pypi.org/project/pyupgrade/),
[autoflake](https://pypi.org/project/autoflake/), and more, all while executing tens or hundreds of
times faster than any individual tool.
Ruff is extremely actively developed and used in major open-source projects like:
- [Apache Airflow](https://github.com/apache/airflow)
- [FastAPI](https://github.com/tiangolo/fastapi)
- [Hugging Face](https://github.com/huggingface/transformers)
- [Pandas](https://github.com/pandas-dev/pandas)
- [SciPy](https://github.com/scipy/scipy)
...and [many more](#whos-using-ruff).
Ruff is backed by [Astral](https://astral.sh). Read the [launch post](https://astral.sh/blog/announcing-astral-the-company-behind-ruff),
or the original [project announcement](https://notes.crmarsh.com/python-tooling-could-be-much-much-faster).
## Testimonials
[**Sebastián RamÃrez**](https://twitter.com/tiangolo/status/1591912354882764802), creator
of [FastAPI](https://github.com/tiangolo/fastapi):
> Ruff is so fast that sometimes I add an intentional bug in the code just to confirm it's actually
> running and checking the code.
[**Nick Schrock**](https://twitter.com/schrockn/status/1612615862904827904), founder of [Elementl](https://www.elementl.com/),
co-creator of [GraphQL](https://graphql.org/):
> Why is Ruff a gamechanger? Primarily because it is nearly 1000x faster. Literally. Not a typo. On
> our largest module (dagster itself, 250k LOC) pylint takes about 2.5 minutes, parallelized across 4
> cores on my M1. Running ruff against our _entire_ codebase takes .4 seconds.
[**Bryan Van de Ven**](https://github.com/bokeh/bokeh/pull/12605), co-creator
of [Bokeh](https://github.com/bokeh/bokeh/), original author
of [Conda](https://docs.conda.io/en/latest/):
> Ruff is ~150-200x faster than flake8 on my machine, scanning the whole repo takes ~0.2s instead of
> ~20s. This is an enormous quality of life improvement for local dev. It's fast enough that I added
> it as an actual commit hook, which is terrific.
[**Timothy Crosley**](https://twitter.com/timothycrosley/status/1606420868514877440),
creator of [isort](https://github.com/PyCQA/isort):
> Just switched my first project to Ruff. Only one downside so far: it's so fast I couldn't believe
> it was working till I intentionally introduced some errors.
[**Tim Abbott**](https://github.com/astral-sh/ruff/issues/465#issuecomment-1317400028), lead
developer of [Zulip](https://github.com/zulip/zulip):
> This is just ridiculously fast... `ruff` is amazing.
<!-- End section: Overview -->
## Table of Contents
For more, see the [documentation](https://docs.astral.sh/ruff/).
1. [Getting Started](#getting-started)
1. [Configuration](#configuration)
1. [Rules](#rules)
1. [Contributing](#contributing)
1. [Support](#support)
1. [Acknowledgements](#acknowledgements)
1. [Who's Using Ruff?](#whos-using-ruff)
1. [License](#license)
## Getting Started
For more, see the [documentation](https://docs.astral.sh/ruff/).
### Installation
Ruff is available as [`ruff`](https://pypi.org/project/ruff/) on PyPI:
```shell
pip install ruff
```
You can also install Ruff via [Homebrew](https://formulae.brew.sh/formula/ruff), [Conda](https://anaconda.org/conda-forge/ruff),
and with [a variety of other package managers](https://docs.astral.sh/ruff/installation/).
### Usage
To run Ruff as a linter, try any of the following:
```shell
ruff check . # Lint all files in the current directory (and any subdirectories).
ruff check path/to/code/ # Lint all files in `/path/to/code` (and any subdirectories).
ruff check path/to/code/*.py # Lint all `.py` files in `/path/to/code`.
ruff check path/to/code/to/file.py # Lint `file.py`.
ruff check @arguments.txt # Lint using an input file, treating its contents as newline-delimited command-line arguments.
```
Or, to run Ruff as a formatter:
```shell
ruff format . # Format all files in the current directory (and any subdirectories).
ruff format path/to/code/ # Format all files in `/path/to/code` (and any subdirectories).
ruff format path/to/code/*.py # Format all `.py` files in `/path/to/code`.
ruff format path/to/code/to/file.py # Format `file.py`.
ruff format @arguments.txt # Format using an input file, treating its contents as newline-delimited command-line arguments.
```
Ruff can also be used as a [pre-commit](https://pre-commit.com/) hook via [`ruff-pre-commit`](https://github.com/astral-sh/ruff-pre-commit):
```yaml
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
```
Ruff can also be used as a [VS Code extension](https://github.com/astral-sh/ruff-vscode) or
alongside any other editor through the [Ruff LSP](https://github.com/astral-sh/ruff-lsp).
Ruff can also be used as a [GitHub Action](https://github.com/features/actions) via
[`ruff-action`](https://github.com/chartboost/ruff-action):
```yaml
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
-
没有合适的资源?快使用搜索试试~ 我知道了~
Python检查器和格式化工具:ruff
共2000个文件
py:1486个
expect:193个
json:121个
需积分: 3 1 下载量 174 浏览量
2024-03-05
21:46:56
上传
评论
收藏 5.96MB ZIP 举报
温馨提示
主要语言:Rust 项目分类:[工具] 项目标签:[开发辅助] [协作工具] [代码规范] 推荐理由:一个非常快速的Python检查器和代码格式化工具,用Rust编写。它旨在帮助开发人员轻松进行Python代码的检查和格式化,提高代码质量和可读性。Ruff的性能卓越,使开发人员能够更高效地管理和维护Python项目。
资源推荐
资源详情
资源评论
收起资源包目录
Python检查器和格式化工具:ruff (2000个子文件)
tailwind.config.cjs 2KB
postcss.config.cjs 83B
CODEOWNERS 564B
extra.css 3KB
index.css 2KB
Dockerfile 1KB
.editorconfig 354B
.editorconfig 236B
.editorconfig 158B
.editorconfig 28B
.eslintrc 691B
preview_long_strings__regression.py.expect 23KB
preview_long_strings.py.expect 19KB
long_strings_flag_disabled.py.expect 11KB
expression.py.expect 9KB
composition.py.expect 5KB
composition_no_trailing_comma.py.expect 5KB
fmtonoff.py.expect 5KB
preview_comments7.py.expect 5KB
docstring.py.expect 4KB
preview_multiline_strings.py.expect 4KB
comments2.py.expect 4KB
comments4.py.expect 3KB
preview_long_strings__edge_case.py.expect 3KB
function.py.expect 3KB
preview_prefer_rhs_split.py.expect 3KB
prefer_rhs_split.py.expect 3KB
pattern_matching_generic.py.expect 3KB
pattern_matching_complex.py.expect 3KB
funcdef_return_type_trailing_comma.py.expect 3KB
preview_hug_parens_with_braces_and_square_brackets.py.expect 3KB
comments9.py.expect 3KB
pattern_matching_simple.py.expect 3KB
return_annotation_brackets.py.expect 3KB
conditional_expression.py.expect 2KB
comments6.py.expect 2KB
pep604_union_types_line_breaks.py.expect 2KB
preview_hug_parens_with_braces_and_square_brackets.py.expect 2KB
empty_lines.py.expect 2KB
class_methods_new_line.py.expect 2KB
comments_in_blocks.py.expect 2KB
conditional_expression.py.expect 2KB
preview_hug_parens_with_braces_and_square_brackets_no_ll1.py.expect 2KB
pep_646.py.expect 2KB
function_trailing_comma.py.expect 2KB
preview_long_dict_values.py.expect 2KB
comments.py.expect 2KB
docstring_no_string_normalization.py.expect 2KB
fmtonoff5.py.expect 2KB
line_ranges_basic.py.expect 2KB
pattern_matching_extras.py.expect 2KB
docstring_preview.py.expect 2KB
power_op_spacing.py.expect 2KB
collections.py.expect 2KB
fmtskip8.py.expect 2KB
preview_cantfit.py.expect 2KB
preview_context_managers_39.py.expect 2KB
context_managers_39.py.expect 2KB
remove_await_parens.py.expect 2KB
remove_parens.py.expect 2KB
remove_newline_after_code_block_open.py.expect 2KB
comments3.py.expect 2KB
preview_power_op_spacing.py.expect 1KB
power_op_spacing_long.py.expect 1KB
import_spacing.py.expect 1KB
remove_with_brackets.py.expect 1KB
torture.py.expect 1KB
function2.py.expect 1KB
debug_visitor.py.expect 1KB
comments5.py.expect 1KB
string_quotes.py.expect 1KB
stub.pyi.expect 1KB
module_docstring_2.py.expect 1KB
dummy_implementations.py.expect 1KB
preview_dummy_implementations.py.expect 1KB
trailing_commas_in_leading_parts.py.expect 1KB
remove_except_parens.py.expect 1018B
pep_654_style.py.expect 991B
pep_654.py.expect 972B
pep_572.py.expect 970B
pep_572_remove_parens.py.expect 932B
preview_form_feeds.py.expect 920B
form_feeds.py.expect 920B
allow_empty_first_line.py.expect 887B
preview_allow_empty_first_line.py.expect 887B
trailing_comma_optional_parens1.py.expect 827B
slices.py.expect 787B
remove_for_brackets.py.expect 734B
preview_long_strings__east_asian_width.py.expect 717B
remove_redundant_parens_in_case_guard.py.expect 685B
pep_570.py.expect 680B
line_ranges_fmt_off.py.expect 677B
skip_magic_trailing_comma.py.expect 644B
nested_stub.pyi.expect 611B
fmtonoff2.py.expect 604B
preview_allow_empty_first_line_in_special_cases.py.expect 580B
type_params.py.expect 579B
prefer_rhs_split_reformatted.py.expect 569B
line_ranges_fmt_off_overlap.py.expect 568B
python37.py.expect 566B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
全栈海哥
- 粉丝: 1624
- 资源: 98
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功