Closed henhuy closed 1 year ago
hi @henhuy this is already supported (and suggested as a fix).
def repaint(*, immediate=True):
pass
def repaint2(immediate=True):
pass
$ flake8 --select FBT ./a.py
./a.py:4:24: FBT002 do not set boolean defaults for positional args. Hint: in `def repaint2(...)`, define `immediate` as kw-only
Note the suggestion is for the second definition only, the first passes fine
Im closing this as already solved. Feel free to re-open if i didn't get your point.
Oh, nice!
Got this error while using ruff. Maybe I didn't use latest ruff version. Thanks for your answer!
$ ruff --select=FBT ./a.py
a.py:4:24: FBT002 Boolean default value in function definition
Found 1 error.
its a pity i cannot share same codebase - fbt for ruff is here
Yes, I understand...
So I should post issue there...
So I should post issue there...
in the next issue, yes. for the current one, i already tried it and it works fine, see https://github.com/pwoolvett/flake8_boolean_trap/issues/8#issuecomment-1479516888 , so there's no need to create another issue...
From my understanding, explicitly set boolean arguments should be allowed. As python supports keyword-only arguments since PEP3102 this could be allowed. Example (borrowed from https://ariya.io/2011/08/hall-of-api-shame-boolean-trap):
So that function must be called using keyword
repaint(immediate=False)
. What do you think?