[flake8-boolean-trap] Add multiprocessing.Value to excluded functions for FBT003#23010
Conversation
Value to excluded functions for FBT003multiprocessing.Value to excluded functions for FBT003
|
|
Thanks for looking into this! Has this change been discussed anywhere on an issue? I'm not sure we want to add more hard-coded exceptions to this rule, especially when you can suppress this diagnostic by configuring the extend-allowed-calls setting. |
|
It has not been discussed anywhere. |
|
It looks like the sqlalchemy special case was added a while before the config option. Can you check the ecosystem results too? It looks like this change is affecting |
|
Certainly 🙂 |
|
Indeed, I'm currently also hitting django.db.models.Value, which was not my intention. |
|
So actually edited the italic Adding it per default allowed is therefore (in my opinion) still a good choice. It would require a new helper in rust though, which does something similar to |
76c36d7 to
077fa6d
Compare
|
@ntBre could you approve the workflows once again? |
|
I think someone did approve the workflows, and the remaining test failures are real. I'm sort of confused by this comment:
I'm looking at the which indicates that >>> import multiprocessing
>>> from ctypes import c_bool
>>> multiprocessing.Value(c_bool, lock=False)
c_bool(False)I'm not very familiar with the usage of |
|
Ah yes, a nasty pitfall. >>> import multiprocessing
>>> from ctypes import c_bool
>>> multiprocessing.Value(c_bool, lock=True)
<Synchronized wrapper for c_bool(False)
|
|
Looking at it I do not think I broke anything but the snaps, which are IIRC (because of my additional three lines in the FBT.py) off by three. Thanks for your patience :) |
|
Ah of course, I think I've come around on this. It makes sense to me to include an exception for the standard library, especially if we're checking the |
for `FBT003`. This method is commonly used in multiprocessing and has no keywords.
077fa6d to
1503830
Compare
|
Took me a second to realize After reviewing the three snap files, I can confirm, the only thing I did was changes of line numbers in them due to my addition in Another option would be to add my new FBT lines at the very bottom, If somebody could give CI another kick, I'd appreciate it. |
multiprocessing.Value to excluded functions for FBT003flake8-boolean-trap] Add multiprocessing.Value to excluded functions for FBT003
|
Nice, thank you! |
Summary
This PR excludes ´multiprocessing.Value("b", boolean)` from FBT003.
As a pure wrappper function and its distinctive capitalization it might be worthwhile to allow it.
Something similar has been done in #6307 after a discussion in #6302.
Test Plan
A new test has been added to the test fixtures of FBT and uses
Valuelike inmultiprocessing.I ran the test locally:
cargo run -p ruff -- check crates/ruff_linter/resources/test/fixtures/flake8_boolean_trap/FBT.py --no-cache --preview --select FBT003