GithubHelp home page GithubHelp logo

astral-sh / ruff Goto Github PK

View Code? Open in Web Editor NEW
26.5K 74.0 849.0 44.88 MB

An extremely fast Python linter and code formatter, written in Rust.

Home Page: https://docs.astral.sh/ruff

License: MIT License

Rust 97.96% Python 1.17% HTML 0.01% TypeScript 0.66% CSS 0.01% JavaScript 0.02% Shell 0.16% Dockerfile 0.01%
linter pep8 python python3 rust rustpython static-analysis static-code-analysis style-guide styleguide

ruff's Introduction

Ruff

Ruff image image image Actions status Discord

Docs | Playground

An extremely fast Python linter and code formatter, written in Rust.

Shows a bar chart with benchmark results.

Linting the CPython codebase from scratch.

  • ⚡️ 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, 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 800 built-in rules, with native re-implementations of popular Flake8 plugins, like flake8-bugbear
  • ⌨️ First-party editor integrations for VS Code and more
  • 🌎 Monorepo-friendly, with hierarchical and cascading configuration

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 (plus dozens of plugins), Black, isort, pydocstyle, pyupgrade, 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:

...and many more.

Ruff is backed by Astral. Read the launch post, or the original project announcement.

Testimonials

Sebastián Ramírez, creator of 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, founder of Elementl, co-creator of GraphQL:

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, co-creator of Bokeh, original author of Conda:

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, creator of 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, lead developer of Zulip:

This is just ridiculously fast... ruff is amazing.

Table of Contents

For more, see the documentation.

  1. Getting Started
  2. Configuration
  3. Rules
  4. Contributing
  5. Support
  6. Acknowledgements
  7. Who's Using Ruff?
  8. License

Getting Started

For more, see the documentation.

Installation

Ruff is available as ruff on PyPI:

pip install ruff

You can also install Ruff via Homebrew, Conda, and with a variety of other package managers.

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.

Or, 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.3.7
  hooks:
    # Run the linter.
    - id: ruff
      args: [ --fix ]
    # Run the formatter.
    - id: ruff-format

Ruff can also be used as a VS Code extension or alongside any other editor through the Ruff LSP.

Ruff can also be used as a GitHub Action via ruff-action:

name: Ruff
on: [ push, pull_request ]
jobs:
  ruff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: chartboost/ruff-action@v1

Configuration

Ruff can be configured through a pyproject.toml, ruff.toml, or .ruff.toml file (see: Configuration, or Settings for a complete list of all configuration options).

If left unspecified, Ruff's default configuration is equivalent to the following ruff.toml file:

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.8
target-version = "py38"

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

Note that, in a pyproject.toml, each section header should be prefixed with tool.ruff. For example, [lint] should be replaced with [tool.ruff.lint].

Some configuration options can be provided via dedicated command-line arguments, such as those related to rule enablement and disablement, file discovery, and logging level:

ruff check --select F401 --select F403 --quiet

The remaining configuration options can be provided through a catch-all --config argument:

ruff check --config "lint.per-file-ignores = {'some_file.py' = ['F841']}"

See ruff help for more on Ruff's top-level commands, or ruff help check and ruff help format for more on the linting and formatting commands, respectively.

Rules

Ruff supports over 800 lint rules, many of which are inspired by popular tools like Flake8, isort, pyupgrade, and others. Regardless of the rule's origin, Ruff re-implements every rule in Rust as a first-party feature.

By default, Ruff enables Flake8's F rules, along with a subset of the E rules, omitting any stylistic rules that overlap with the use of a formatter, like ruff format or Black.

If you're just getting started with Ruff, the default rule set is a great place to start: it catches a wide variety of common errors (like unused imports) with zero configuration.

Beyond the defaults, Ruff re-implements some of the most popular Flake8 plugins and related code quality tools, including:

For a complete enumeration of the supported rules, see Rules.

Contributing

Contributions are welcome and highly appreciated. To get started, check out the contributing guidelines.

You can also join us on Discord.

Support

Having trouble? Check out the existing issues on GitHub, or feel free to open a new one.

You can also ask for help on Discord.

Acknowledgements

Ruff's linter draws on both the APIs and implementation details of many other tools in the Python ecosystem, especially Flake8, Pyflakes, pycodestyle, pydocstyle, pyupgrade, and isort.

In some cases, Ruff includes a "direct" Rust port of the corresponding tool. We're grateful to the maintainers of these tools for their work, and for all the value they've provided to the Python community.

Ruff's formatter is built on a fork of Rome's rome_formatter, and again draws on both API and implementation details from Rome, Prettier, and Black.

Ruff's import resolver is based on the import resolution algorithm from Pyright.

Ruff is also influenced by a number of tools outside the Python ecosystem, like Clippy and ESLint.

Ruff is the beneficiary of a large number of contributors.

Ruff is released under the MIT license.

Who's Using Ruff?

Ruff is used by a number of major open-source projects and companies, including:

Show Your Support

If you're using Ruff, consider adding the Ruff badge to your project's README.md:

[![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)

...or README.rst:

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
    :target: https://github.com/astral-sh/ruff
    :alt: Ruff

...or, as HTML:

<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff" style="max-width:100%;"></a>

License

MIT

ruff's People

Contributors

akx avatar alexwaygood avatar andersk avatar augustelalande avatar burntsushi avatar charliermarsh avatar cnpryer avatar colin99d avatar davidszotten avatar dependabot[bot] avatar dhruvmanila avatar diceroll123 avatar edgarrmondragon avatar evanrittenhouse avatar harupy avatar jonathanplasse avatar konstin avatar labatata101 avatar messense avatar michareiser avatar not-my-profile avatar qdegraaf avatar renovate[bot] avatar saadmk11 avatar sbrugman avatar snowsignal avatar spaceone avatar squiddy avatar tjkuson avatar zanieb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruff's Issues

Make throwaway variable (`_`) pattern configurable

There are cases where _ cannot be used to mark a throwaway variable and it would be great if ruff allowed configuring it. This is common in projects that use gettext for example, as _ is used for translating strings there. One of the ways unused variables are marked in such projects is using __ (double underscore) but it probably would be a good idea to just make it configurable with a sane default to appeal to more uses.

Notably, pylint allows configuring the dummy variable pattern with a regex:
https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#dummy-variables-rgx

Consider using `libcst`

https://github.com/Instagram/LibCST

It is partially written in Rust and allows you to have way more over the syntax tree.
It will allow code rewrite and will allow more syntax checks.

I highly recommend trying this before the project will have a lot of exisiting source code.

Refactor AST traversal to support batched visitors

Right now, we're able to get away with a single visitor implementation that implements all rules. We'll need to evolve this to something closer to Fixit's model: multiple visitors that deal with isolated concerns, and can be batched and run in a single traversal.

Comparison with flake8?

As mentioned in #119, ruff looks great and I'd love to adopt it in pydantic, however I'd like to have a better understanding of what I loose by switching from flake8 to ruff?

I've run ruff on pydantic and apart from #119, ruff has found a few legitimate things that I would either fix or ignore. The problem is what checks am I no longer getting?

This is harder to find without either a lot of trial or waiting to get bitten.

I would therefore find it really helpful if there was a good comparison of ruff and flake8. I'm sure other potential users would also find this helpful.

Providing a directory as an argument causes panic

RUST_BACKTRACE=full ruff celery
thread '<unnamed>' panicked at 'removal index (is 20) should be < len (is 20)', src/check_lines.rs:35:16
stack backtrace:
   0:        0x10ca52807 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85521558a183f368
   1:        0x10c876a4b - core::fmt::write::h01631fae0d2b98bc
   2:        0x10ca4d8bc - std::io::stdio::_print::h3f48a1f06c5dc1b5
   3:        0x10ca56db0 - std::panicking::default_hook::h18647b59f1a84ee2
   4:        0x10ca56acc - std::panicking::default_hook::h18647b59f1a84ee2
   5:        0x10ca57368 - std::panicking::rust_panic_with_hook::hd9ead35a68ccc55e
   6:        0x10ca572a4 - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h4eaac086dd1f05c5
   7:        0x10ca55da7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85521558a183f368
   8:        0x10ca56fc0 - _rust_begin_unwind
   9:        0x10ca7f683 - core::panicking::panic_fmt::h3d9f795ee387ef8d
  10:        0x10ca7b176 - alloc::vec::Vec<T,A>::remove::assert_failed::h110daa08131a2fb6
  11:        0x10c9232a8 - ruff::linter::check_path::he0f23175143f4a67
  12:        0x10c938891 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  13:        0x10c936a43 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  14:        0x10c92a320 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  15:        0x10c936ddf - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  16:        0x10c92a3ff - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  17:        0x10c936ddf - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  18:        0x10c92a3ff - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  19:        0x10c936ddf - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  20:        0x10c92a320 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  21:        0x10c936ddf - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  22:        0x10c937693 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  23:        0x10ca82306 - rayon_core::registry::WorkerThread::wait_until_cold::h6c4b4c23a2ed2f5c
  24:        0x10c92a4d2 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  25:        0x10c936ddf - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  26:        0x10c937693 - ruff::settings::Settings::ignore::h00b9e252c6691a0f
  27:        0x10ca82306 - rayon_core::registry::WorkerThread::wait_until_cold::h6c4b4c23a2ed2f5c
  28:        0x10c8acdf0 - rayon_core::registry::ThreadBuilder::run::ha91e61928ff63c4e
  29:        0x10c8a9e72 - _rust_eh_personality
  30:        0x10c8ab17f - _rust_eh_personality
  31:        0x10ca5a8f9 - std::sys::unix::thread::Thread::new::h2ee6b50b075520a6
  32:     0x7ff80e4b94e1 - __pthread_start
zsh: abort      RUST_BACKTRACE=full ruff celery

Implement autofix

What's the right strategy for autofixing? Should we modify the AST? Should we use the generated rules, and modify via regex? (This is what autoflake does, and there's a start on implementing autofix for F401 in #34.)

ruff incorrectly flags imports included in __all__

Steps to reproduce

  1. Create two files, __init__.py and blah.py.

blah.py

class MyBlahClass:
    pass

__init__.py

from blah import MyBlahClass

__all__ = ["MyBlahClass"]
  1. Run ruff

Expected results
2. ruff should not have an issue with the import in MyBlahClass as it's included in __all__.

Actual results
2. ruff reports a F401, class imported but unused

ruff output:

ruff . -v  
[2022-09-01][15:17:28][ruff][DEBUG] Identified files to lint in: 25.778µs
[2022-09-01][15:17:28][ruff::linter][DEBUG] Cache hit for: ./blah.py
[2022-09-01][15:17:28][ruff::linter][DEBUG] Cache hit for: ./__init__.py
[2022-09-01][15:17:28][ruff][DEBUG] Checked files in: 588.674µs
Found 1 error(s).

./__init__.py:1:1: F401 `blah.MyBlahClass` imported but unused

flake8 output:

flake8 . -v
flake8.checker            MainProcess     53 INFO     Making checkers
flake8.checker            MainProcess     54 INFO     Checking 2 files
flake8.main.application   MainProcess     71 INFO     Finished running
flake8.main.application   MainProcess     71 INFO     Reporting errors
flake8.main.application   MainProcess     71 INFO     Found a total of 0 violations and reported 0

`Invalid syntax. Got unexpected token 'as'` on multiple `... as ...` inside a with statement

Found this bug while testing ruff on my code, here is a simplified example to reproduce:

main.py:

with (
    open("test", "r") as f,
    open("test2", "r") as f2,
):
    print("hello")

ruff output:

[2022-09-01][14:00:00][ruff::pyproject][DEBUG] Found pyproject.toml at: pyproject.toml
[2022-09-01][14:00:00][ruff][DEBUG] Identified files to lint in: 3.25µs
[2022-09-01][14:00:00][ruff][ERROR] Failed to check main.py: invalid syntax. Got unexpected token 'as' at line 2 column 23
[2022-09-01][14:00:00][ruff][DEBUG] Checked files in: 174.625µs
Found 0 error(s).

Erroneous F821 on classes with parameter type annotations

If I run ruff on a file containing a class with a type annotation at class level, it incorrectly gives F821 (undefined name).

Examples:

from dataclasses import dataclass


@dataclass
class Bad:
    x: int


@dataclass
class AlsoBad:
    x: int = 3


class StillBad:
    x: int

    def __init__(self):
        self.x = 3


class Ok:
    x = 3

Running ruff <filename> on this file gives:

ruff_test.py:6:5: F821 Undefined name `x`
ruff_test.py:11:5: F821 Undefined name `x`
ruff_test.py:15:5: F821 Undefined name `x`

(flake8 gives no errors)

Ruff version 0.0.28, python 3.8.13, ubuntu 22.04.1.

Handle multiple unused submodule imports

pylint does this properly, Flake8 does not.

For example, with this:

import multiprocessing.pool
import multiprocessing.process

Flake8 will only mark the second import as unused.

`F401` when type used in annotation

Kind of the opposite to #128.

E.g. NamedTuple is imported here, and used here.

But shows up in errors:

pydantic/annotated_types.py:2:1: F401 `typing.NamedTuple` imported but unused

There are currently 30 of these errors from running ruff on pydantic.

As with #128, I've build ruff from main (a8f4faa).

`F821` on use of `Literal` with strings, e.g. `Literal['foo']`

Since #119 was fixed via #125, I tried ruff again (build from main) with pydantic.

I get a few remaining F821 errors due to use of strings in Literal, the line numbers are also incorrect - seems to always be 1.

From this code (and some other places in that file), I get:

pydantic/config.py:1:1: F821 Undefined name `deep`
pydantic/config.py:1:1: F821 Undefined name `none`
pydantic/config.py:1:1: F821 Undefined name `deep`
pydantic/config.py:1:1: F821 Undefined name `shallow`
pydantic/config.py:1:1: F821 Undefined name `before_validation`
pydantic/config.py:1:1: F821 Undefined name `after_validation`
pydantic/config.py:1:1: F821 Undefined name `none`
pydantic/config.py:1:1: F821 Undefined name `shallow`
pydantic/config.py:1:1: F821 Undefined name `before_validation`
pydantic/config.py:1:1: F821 Undefined name `after_validation`

Example code:

    copy_on_model_validation: Literal['none', 'deep', 'shallow']
    post_init_call: Literal['before_validation', 'after_validation']

pre-commit hook does not consider configuration in pyproject.toml.

I have tested pre-commit hook and it works fine but when I tried to implement a new configuration in pyproject.toml, I realized it does not consider the configuration.

[tool.ruff]
line-length = 200
ignore = ['E501', 'F841']

I still get the error E501 even though I have ignored it.
Screenshot from 2022-09-09 23-50-25

F401 `__future__.annotations` imported but unused

ruff marks from __future__ import annotations imports as unused. They are not supposed to be used, and so shouldn't be reported.

models.py:1:1: F401 `__future__.annotations` imported but unused

Implement AST-to-source code generation

Not critical but this could be somewhat useful for autofixing. Similar to astor. The main issue with AST-to-code generation is that it's impossible to preserve formatting, including comments and docstrings, since those aren't captured in the AST. That's a big limitation, and means that you can really only use this for reconstructing small subtrees.

Lint a directory recursively

It'd be useful to have a way to lint all Python files in a directory and its subdirectories using a CLI option.

Support for E712 and others

Dear Charlie,

thanks a stack for conceiving this excellent program. While working on modernizing an outdated code base [1,2], we started using ruff just recently, and are amazed by its speed. Currently, we would never look back.

As we got the chance to work on this code base, originally from Python 2, but now already ported to Python 3 and polished off with ruff and black, we thought it would be a good idea to report back what flake8 would still observe on it.

The error codes are: E203, E711, E712, E713, E741, F841, where E712 was the most popular, followed by its neighbors E711 and E713, as well as F841.

With kind regards,
Andreas.

[1] https://github.com/isarengineering/SecPi/tree/next
[2] SecPi/SecPi#120

`F821 Undefined name` when definition is after usage

Ruff looks great, congratulations. I'd love to use it one day on pydantic instead of flake8.


The following code is valid python and runs fine

def main():
    foo()

def foo():
    print('this is foo')

main()

However ruff returns:

test.py:2:5: F821 Undefined name `foo`

Found 1 error(s).

Running ruff on pydantic's code base is currently returning 151 F821 errors, so it's a fairly common problem.

Results that do not meet expectations

main.py

from flask import Flask

def make_app():
    app = Flask(__name__)
    return app

app = make_app()

Results:

$ ruff main.py
Found 1 error(s).

main.py:7:7: F821 Undefined name `make_app`
$ flake8 main.py
main.py:3:1: E302 expected 2 blank lines, found 1
main.py:7:1: E305 expected 2 blank lines after class or function definition, found 1

Crash on parenthesized with statement

I tried running ruff on a large project, which resulted in this crash:

[2022-08-31][10:33:40][ruff][ERROR] Failed to check repr-with.py: invalid syntax. Got unexpected token 'as' at line 9 column 13

It seems like the crash happens on parenthesized context managers introduced in Python 3.10. Minimal reproducible example:

from contextlib import contextmanager

@contextmanager
def ctx():
    yield

with (ctx() as foo):
    ...

`F401 imported but unused` when symbol is only used for type hints

Hi Charlie,

maybe similar to #83, ruff also marks spots as "imported but unused", where the imported symbols are only used within type hints.

With kind regards,
Andreas.

Example

import dataclasses
from datetime import datetime


@dataclasses.dataclass
class Message:
    message: str
    datetime: datetime

Crash if no pyproject.toml file is found

Hey!

Great project! I just found a bug that occurs if ruff cannot find a pyproject.toml file. It will assume that
there is a pyproject.toml file at $HOME/.ruff. When trying to parse it, the program crashes (silently) with a file not found error.

To reproduce:

Try running ruff in a location where it cannot find a pyproject.tomlfile at all.

I already forked and fixed the bug :)

No obvious way to use a glob or regexp pattern in `exclude`

With many Django apps in one project, one usually has a lot of auto-generated DB migrations, each under its own app directory. It looks like so:

apps/foo/migrations/...
apps/bar/migrations/...

It would be great to be able to match them in one exclude pattern, like apps/*/migrations, or, **/migrations/, or even just /migrations/.

None of these appears to work right now; the only to list every app explicitly.

Settings: Support the `ignore` option also within `pyproject.toml`

Hi again,

after running into #119 as well, we tried to ignore F821 by adding it to the pyproject.toml file within the [tool.ruff] section, like:

[tool.ruff]
ignore = ["F821"]

However, ruff complained with:

Failed to load pyproject.toml: unknown field `ignore`, expected one of `line-length`, `exclude`, `select` for key `tool.ruff` at line 199 column 1

It looks like the option, although being implemented within settings.rs, is currently only available as a command line option, to be used like ruff --ignore=F821 .. I think it would be sweet to be en par with flake8 in this case, because ignore will probably be a popular option.

With kind regards,
Andreas.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.