-
Notifications
You must be signed in to change notification settings - Fork 18
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
Handle @option tags #68
Conversation
At least, what I expect them to look like.
Also update RbiGenerator spec.
I found this issue in Bundler, now it should generate the correct signatures.
You can find these in the files generated with the seed task by searching for |
One other problem I just noticed (will probably fix it tomorrow, feel free to fix it yourself if you want), the options parser will accept invalid keys, this happens in the GitLab gem a decent amount: Input: # Get all license templates.
# @param [Hash] options A customizable set of options.
# @option options [Boolean] popular(optional) If passed, returns only popular licenses.
# @return [Array<Gitlab::ObjectifiedHash>]
def license_templates(options = {})
get('/templates/licenses', query: options)
end Output: sig { params(key: String, options: { project(optional): String, fullname(optional): String }).returns(Gitlab::ObjectifiedHash) }
def license_template(key, options = {}); end These should probably output SORD_ERRORs? |
Another problem: Sorbet doesn't currently have a way to make the key/value pairs in a Shape optional :/ This is probably not a good idea to merge, then. Maybe put it behind a flag or something? |
The lack of optional keys in shapes is a real nuisance!
I suppose it could go behind a flag called I have devised an incredibly hacky and horrible-feeling solution that is quite honestly a disgrace to Sorbet, Edit: Yeah, this really doesn't work because of shapes allowing extra keys. It'll keep going down the list of types in |
I had a look through Sorbet's own RBIs to see how they chose to implement this, but it looks as if they're mostly just typed as |
I opened an issue to add optional key/value pairs in Shapes: sorbet/sorbet#1160 |
I would say without the ability for optional key/value pairs, this isn't worth bothering with. Maybe just have Sord detect |
Yeah, I'd say that would be the best course of action for now. |
I'd say the benefits aren't really worth the trouble right now, so I'm closing this. |
Implements #59.
Input:
Output (Before):
Output (After):
Adds five test cases.
I didn't update
sord.rbi
as part of this so as not to conflict with #67, but you should probably regenerate it after merging this (if you merge it). Then the keys available in theoptions
hash for theRbiGenerator
initializer will be explicitly specified :)