-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Decorator on method in derived class #1441
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
Comments
Actually, that work-around doesn't currently work. Adding the decorator to |
Looking at the code a bit, it looks like check_method_override(), which is supposed to check whether Derived.f is compatible with Base.f, is called with the undecorated function. I'm guessing the decorator is stripped off somewhere a little earlier -- in fact, it seems the cuprit here is visit_decorator() that just calls e.func.accept(). |
We really should fix this one! |
More examples in #2469. |
The fix turned out to be pretty complicated, as there were a bunch of untested method overriding scenarios which weren't quite right. I fixed any related issues that I encountered, though I'm not certain whether some of the issues were hidden previously by other bugs. I also added tests for some related, previously untested scenarios. Fixes #1441.
The fix turned out to be pretty complicated, as there were a bunch of untested method overriding scenarios which weren't quite right. I fixed any related issues that I encountered, though I'm not certain whether some of the issues were hidden previously by other bugs. I also added tests for some related, previously untested scenarios. Fixes #1441.
A decorator that changes the signature of a function is rejected if the old signature isn't consistent with the superclass. E.g.:
The interesting point here is that the base class doesn't use the decorator while the child does. Our particular issue is in code that uses contextlib.contextmanager, but I think we can work around it by adding the decorator to the base class.
The text was updated successfully, but these errors were encountered: