[flake8-boolean-trap] Add setting for user defined allowed boolean trap#10531
[flake8-boolean-trap] Add setting for user defined allowed boolean trap#10531charliermarsh merged 5 commits intoastral-sh:mainfrom
flake8-boolean-trap] Add setting for user defined allowed boolean trap#10531Conversation
|
|
Is it possible to also check the import path like it should check "django.db.models.Value" and not just "Value" usage? |
| "Field".to_string(), | ||
| "settings".to_string(), | ||
| "deploy".to_string(), | ||
| "used".to_string(), |
There was a problem hiding this comment.
It's not clear to me if these should be function names, or symbol paths (like ["pydantic", "BaseModel"]).
There was a problem hiding this comment.
Do you mean it's not clear in the documentation/implementation? Or are you saying you're not sure how we should implement it?
There was a problem hiding this comment.
I think symbol path gives finer control, and is less prone to false negatives. The only downside is that it is less intuitive to users, and may lead to confusion. But I think this should be ok with good documentation.
There was a problem hiding this comment.
I will change it to symbol paths if everyone agrees.
There was a problem hiding this comment.
Symbol path is a little problematic because it doesn't support methods (e.g., there's no way to identify y in x = pydantic.BaseModel(); x.y()), and methods are a common use-case here.
|
@charliermarsh I'm moving the discussion to the main thread. Given your comment I think you do not want to drop support for simple function calls. Then there are three options:
|
|
I lean more towards 2, but not strongly |
|
Let me quickly cross-reference with some other settings. |
|
The two linked examples, at least, seem like they would work with symbol paths. So let's start with that. ( |
|
Done |
Summary
Add a setting
extend-allowed-callsto allow users to define their own list of calls which allow boolean traps.Resolves #10485.
Resolves #10356.
Test Plan
Extended text fixture and added setting test.