astral-sh / astral-sh/ruff

Support glob patterns for `extend-immutable-calls` configuration

Open
#4,355 0 comments 0 reactions 0 assignees View on GitHub
configuration
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

## Description

Currently, the configuration of [`extend-immutable-calls`](https://beta.ruff.rs/docs/settings/#extend-immutable-calls) in `pyproject.toml` supports specifying individual functions or attributes, like this:

```toml
[tool.ruff.flake8-bugbear]
extend-immutable-calls = ["betterproto.string_field"]
```

However, it would be beneficial if the tool could also support using glob patterns to match multiple attributes or functions at once. For example:

```toml
[tool.ruff.flake8-bugbear]
extend-immutable-calls = ["betterproto.*"]
```

In this case, the `*` would act as a wildcard, representing any attribute or function within the `betterproto` module.

## Use case

Supporting glob patterns in the configuration would allow users to more easily and concisely specify multiple attributes or functions that they would like to extend with immutable calls. This feature would be particularly useful when a module has many attributes or functions that need to be included in the configuration.

## Proposed solution

Enhance the configuration parser to support glob patterns in the `extend-immutable-calls` list, expanding them to match any applicable attributes or functions within the specified module.

---

Thank you for considering this feature request. I believe it would greatly improve the usability and flexibility of the configuration options.

Contributor guide

Open the contributing guide

Research direction

Start with Ruff's configuration parser and the handling of the `extend-immutable-calls` list. Determine how the existing individual function and attribute names are parsed, then verify that a pattern such as `betterproto.*` matches the intended module members without changing existing exact-name behavior. Done means the configuration accepts glob patterns and tests cover both glob and exact entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.