Open harahu opened 1 day ago
All Ruff rules don't understand Protocols, or class inheritance (with few hardcoded exceptions) because Ruff doesn't support multifile analysis (it doesn't understand the Protocol
type nor can it resolve the class A
if it is defined in another file).
For now, I suggest that you add a @typing.override
decorator to B.foo
. It let's Ruff know that this is an overridden method and that extra arguments are intentional.
I appreciate your clear explanation of the current limitations of ruff. Also appreciate the advice on @typing.override
. Thanks!
I understand that there is a significant backlog of features hinging on type inference and multi-file analysis, so I wish you guys all the best in working towards those. Ruff is already really great, but would undoubtedly be even better with those capabilities implemented.
The ruff rule
ARG003: unused-class-method-argument
does not seem to understand that unused arguments sometimes are necessary in order to implement a protocol. See example below:https://play.ruff.rs/204c57b4-a35e-48d5-8f92-ca2e109dd2cd
This problem appears in ruff 0.6.9