Always removing the first parameter's type annotation when its name is "self" can mask underlying issues in the C++ binding, which is more obviously revealed when you only remove the parameter's annotation when it matches the class name it is bound to or it is typing.Any.
I noticed this bug since there was an unused import in demo/_bindings/aliases/foreign_method_arg.pyi, which seemed strange until I noticed that the sole parameter was actually in fact typed as a Foo in the C++ code (the C++ method implementation is missing a self parameter). I think making this change will help to make these bugs in the underlying C++ code more obvious:
I thought that it would be nice to produce a warning when we find a suspicious self annotation.
If the problem is reliably detectable by static analysis checkers, we don't need to.
Always removing the first parameter's type annotation when its name is
"self"
can mask underlying issues in the C++ binding, which is more obviously revealed when you only remove the parameter's annotation when it matches the class name it is bound to or it istyping.Any
.I noticed this bug since there was an unused import in
demo/_bindings/aliases/foreign_method_arg.pyi
, which seemed strange until I noticed that the sole parameter was actually in fact typed as aFoo
in the C++ code (the C++ method implementation is missing aself
parameter). I think making this change will help to make these bugs in the underlying C++ code more obvious: