8000 Don't require redundant attribute @return and @param tags by apiology · Pull Request #748 · castwide/solargraph · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't require redundant attribute @return and @param tags #748

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

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

apiology
Copy link
Contributor

If the underlying instance variable is already typed (either via @type or via creation from a typed initializer param), don't require attributes (e.g., attr_accessor, attr_reader, etc.) to have redundant @return and @param tags, even under strong typechecking.

If the underlying instance variable is already typed (either via @type
or via creation from a typed initializer param), don't require
attributes (e.g., attr_accessor, attr_reader, etc.) to have redundant
@return and @param tags, even under strong typechecking.
@castwide
Copy link
Owner

This change looks like solid inference from static code analysis. I have plans to replace Solargaphs's @type tag with a @var tag, but that's mostly beside the point here (I just want to make a new tag that's more expressive where local/instance variables are concerned.). Anywhere we can infer correctly from a single tag is a win, wherever that tag happens to be.

Lon 8000 g story short, I'm inclined to merge this PR, but I need to check on a couple things first.

@castwide
Copy link
Owner

One of the updates I'm planning is a feature to generate RBS from a combination of YARD docs and Solargraph's type inference. This PR, in addition to providing smarter typechecking, gets us another step closer to comprehensive RBS without requiring redundant tags when the inferred types are sufficient. Thanks again, @apiology!

@castwide castwide merged commit d00ea55 into castwide:master Feb 22, 2025
8 checks passed
@apiology
Copy link
Contributor Author
apiology commented Feb 22, 2025

Yeah, I love the idea.

I've been playing around with using @AaronC81's https://github.com/AaronC81/sord and https://github.com/AaronC81/parlour to use my yard type annotations supplemented with judicious use of Sorbet/RBI annotations when needed to feed into Sorbet's engine and to generate .rbi and .rbs files to package with my published gems: https://github.com/apiology/cookiecutter-gem/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/Makefile#L31-L41

At a higher level - seems like we want to let annotations interoperate between and inside gems and local source files so we're not throwing away information.

Once we have that, I think we should think about decoupling inference and type checking engines from annotation processors so we can focus energy on having really high quality implementations of all three.

...one step at a time :)

@apiology
Copy link
Contributor Author
apiology commented Feb 22, 2025

@Morriar just dropped support for RBS comments in Sorbet - sorbet/sorbet#8470

I haven't played around with it yet, but it's in line with these thoughts (excuse the pun): https://sorbet.org/docs/rbs-support

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
0