astral-sh / astral-sh/ruff

`flake8-boolean-trap.extend-allowed-calls` don't resolve class types

Open
#11,264 5 comments 4 reactions 0 assignees View on GitHub
type-inference wish
Dominant language
Rust
Stars
49.7k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

I am actually working on fixing the rule **boolean-positional-value-in-call (FBT003)** on a code repository.

I need to allow this rule for some functions. For that, at the end of my config file "pyproject.toml", I have added:

```
[lint.flake8-boolean-trap]
extend-allowed-calls = ["LibName.className.functionName"]
```

My issue here is that in my code repository, we call the function "LibName.className.functionName" through a variable, as following:

```
from LibName import ClassName

with ClassName("[Description]") as variable:
variable.functionName(...)
```

On such code, the rule FBT003 is **still applied** in spite of the "extend-allowed-calls" option.

Is the "extend-allowed-calls" option only works for direct function calls?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the FBT003 example with the shown pyproject.toml configuration and the ClassName context manager pattern. Trace how extend-allowed-calls handles direct calls versus variable.functionName calls; done means the behavior is either correctly supported for the reported pattern or clearly documented if only direct calls are intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.