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.
|
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-runtimeso 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 likearityorparameters. (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.