ruff #### * GitHub: https://github.com/astral-sh/ruff * An extremely fast Python linter and code formatter, written in Rust. 安装:: pip install ruff Usage ===== To run Ruff as a linter, try any of the following:: 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. To run Ruff as a formatter:: 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 hook via ruff-pre-commit:: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.4.4 hooks: # Run the linter. - id: ruff args: [ --fix ] # Run the formatter. - id: ruff-format