Remove use of module_function#150
Merged
martinemde merged 1 commit intorubyatscale:mainfrom Dec 17, 2025
Merged
Conversation
6a01c0c to
4fc00a6
Compare
dduugg
commented
Dec 16, 2025
| # or nil if it can't find anything | ||
| sig { params(klass: T.nilable(T.any(T::Class[T.anything], Module))).returns(T.nilable(String)) } | ||
| def path_from_klass(klass) | ||
| sig { params(klass: T.nilable(T.any(T::Class[T.anything], T::Module[T.anything]))).returns(T.nilable(String)) } |
Contributor
Author
There was a problem hiding this comment.
Module is generic in recent sorbet releases, and required at typed: strict: sorbet/sorbet#9580
| @@ -1,4 +1,4 @@ | |||
| # typed: false | |||
| # typed: strict | |||
Contributor
Author
There was a problem hiding this comment.
This is an easy type promotion 📈
| let(:codes_team) { instance_double(CodeTeams::Team) } | ||
|
|
||
| before do | ||
| allow(codes_team).to receive(:is_a?).with(CodeTeams::Team).and_return(true) |
Contributor
Author
There was a problem hiding this comment.
This is needed bc runtime typechecking is enabled as a result of removing module_function. (See sorbet/sorbet#8531 linked in the PR summary.)
| spec.add_dependency 'code_teams', '~> 1.0' | ||
| spec.add_dependency 'packs-specification' | ||
| spec.add_dependency 'sorbet-runtime', '>= 0.5.11249' | ||
| spec.add_dependency 'sorbet-runtime', '>= 0.6.12763' |
Contributor
Author
There was a problem hiding this comment.
A more recent release is necessary for T::Module to resolve (see comment below).
4fc00a6 to
67bb6ea
Compare
67bb6ea to
07c898b
Compare
martinemde
approved these changes
Dec 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sorbet-runtime does not work on
sigs defined on module_function methods, when called as class methods: sorbet/sorbet#8531tapioca also fails to include type information for the class method versions when generating gem shims: Shopify/tapioca#2000
AFAICT, the instance version of methods created with
module_functionare not used, so this PR proposes using the class definitions only. (This ofc may not be true for dependents, so this is very much a breaking change.)There are some other light changes for compatibility, which i'll comment on below.