-
Notifications
You must be signed in to change notification settings - Fork 42
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
Optional sorbet-runtime
support for JobIteration::Iteration
interface validation
#47
Conversation
Methods that have Sorbet signatures are wrapped by `sorbet-runtime` so that they can be type-checked for correct params/return-value at runtime. However, that wrapper does not and cannot relay the whole information about the original method like `arity` or `parameters`. (Ref: sorbet/sorbet#2643) The workaround is to access the original method from the signature if we detect Sorbet is activated and the method in question has a signature. This commit abstracts the method parameter extraction into a separate method in order to carry out that workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @paracycle!
Thanks! Is there any other things we can make to Iteration jobs typed? Can we use an actual Sorbet interface to enforce all subclasses to respond to right methods and signatures? |
Unfortunately they only work if the class implementing the interface is also typed. HOWEVER. IIRC the check for the |
Can't we make
The framework only allows Maybe I'm misunderstanding you, but the whole |
Cool! I remember correctly that we added this specific check during the transition between
Oh. To check what error message would be produced I commented the check, picked a random task, and removed the
Unfortunate :(. Maybe with 2.7 that error would be better?
We can, but that doesn't force the specific maintenance tasks to be typed so I don't think it solves the problem. |
Methods that have Sorbet signatures are wrapped by
sorbet-runtime
so that they can be type-checked for correct params/return-value at runtime. However, that wrapper does not and cannot relay the whole information about the original method likearity
orparameters
. (Ref: sorbet/sorbet#2643)The workaround is to access the original method from the signature if we detect Sorbet is activated and the method in question has a signature.
This PR abstracts the method parameter extraction into a separate method in order to carry out that workaround and adds a test to ensure that interface validation works even when the interface methods are wrapped by Sorbet.