Skip to content

tapioca gem misses sig for module_function methods of the class variety #2000

Description

@ryanong

When generating sorbet/rbi/gems/code_ownership@1.37.0.rbi with tapioca gem code_ownership module_function defined methods will be created without signatures.

# Gemfile
source "https://rubygems.org"

gem 'tapioca', require: false, :group => [:development, :test]
gem "code_ownership", "1.37.0"

Specifically

# code_ownership.rb

module CodeOwnership
  module_function
  sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }
  def for_class(klass); end
end

will be turned into

# code_ownership.rbi

module CodeOwnership
  sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }; def for_class(klass); end

  class << self
    def for_class(klass); end
  end
end

should be turned into

# code_ownership.rbi

module CodeOwnership
  sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)); def for_class(klass); end

  class << self
    sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }; def for_class(klass); end
  end
end

OR

# code_ownership.rbi

module CodeOwnership
  module_function
  sig { params(klass: T.nilable(T.any(::Module, T::Class[T.anything]))).returns(T.nilable(::CodeTeams::Team)) }; def for_class(klass); end
end

I tried testing this in the rbi gem but it correctly parsed the module to the last one above

I'll gladly dive into the code to fix this if somebody could point out where this is an issue. I did some code diving as you can see already but I'm a bit lost where

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help-wantedWe support this change, and welcome community contributions for it.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions