-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flake8-boolean-trap
] Add setting for user defined allowed boolean trap
#10531
[flake8-boolean-trap
] Add setting for user defined allowed boolean trap
#10531
Conversation
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it to symbol paths if everyone agrees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it hard to support both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-calls
to 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.