Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 do not remove self parameter annotation when types do not match #195

Conversation

ringohoffman
Copy link
Contributor

@ringohoffman ringohoffman commented Nov 24, 2023

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:

Screenshot 2023-11-23 at 5 55 31 PM

always removing the first parameter's type annotation when it is named self masked an underlying issue in the C++ binding, which is revealed when you only remove the parameter's annotation when it matches the class name it is bound to or it is typing.Any
@sizmailov
Copy link
Owner

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.

@sizmailov sizmailov enabled auto-merge (squash) November 24, 2023 04:32
@sizmailov sizmailov merged commit 56cb90a into sizmailov:master Nov 24, 2023
15 checks passed
@ringohoffman ringohoffman deleted the fix-replacing-self-arg-annotation-when-type-mismatch branch November 24, 2023 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants