Open dosisod opened 1 year ago
what would "properly named" even mean?
FBT would raise once for the __init__
, and once for the instantiation.
Are you talking about both?
I agree that "properly named" is a bit vague, which is why it is subjective. And yes I'm suggesting that both instances should not emit an error.
With that in mind, if you truly don't want your users to call your function with keyword arguments, you should probably be using a positional-only argument anyways:
class BooleanExpression:
def __init__(self, value: bool, /) -> None: # notice the `/`
self.value = value
BooleanExpression(True)
In this case, the intent that positional args are indented is explict, and an error shouldn't be emitted (in both cases). In fact, changing True
to value=True
will result in an exception:
Traceback (most recent call last):
File "file.py", line 5, in <module>
BooleanExpression(value=True)
TypeError: BooleanExpression.__init__() got some positional-only arguments passed as keyword arguments: 'value'
So I guess forget what I said about single arg functions, I would much rather use positional-only arguments in this instance. FBT shouldn't be telling to use a keyword argument for a positional only arg in functions though.
IMO, the following should not emit an error:
Assuming that the function/class is properly named, using
value=True
in this case shouldn't be necessary. That is just my opinion though, so having the option to turn it off in this particular case would be nice.