Skip to content
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

Support passing types through keyrest #1451

Open
aaronmallen opened this issue Dec 30, 2024 · 0 comments
Open

Support passing types through keyrest #1451

aaronmallen opened this issue Dec 30, 2024 · 0 comments

Comments

@aaronmallen
Copy link

Currently if you define a type as a record type and attempt to pass a variable having that type with a keyrest Steep will raise a InsufficientKeywordArguments error. For example:

class MyClass
  # @rbs!
  #   type option_type = { foo: String, bar: String, baz: String }

  # @rbs @options: option_type

  attr_reader :options #: option_type

  # @rbs () -> void
  def initialize
    @options = { foo: 'foo', bar: 'bar', baz: 'baz' }
  end

  # @rbs (foo: String, bar: String, baz: String) -> void
  def foo(foo:, bar:, baz:)
    # ...
  end

  # @rbs () -> void
  def bar
    foo(**options) # this will cause Steep to raise InsufficientKeywordArguments
  end

  # @rbs () -> void
  def baz
    foo_options = options
    # @type var foo_options: option_type
    foo(**foo_options) # this will STILL cause Steep to raise InsufficientKeywordArguments
  end
end

It would be awesome if:

  • given an ivar or variable has a type and it is a record type
    • given the record type has all the keys and types necessary to satisfy the keyword arguments
      • steep does not raise InsufficientKeywordArguments
    • given a key mismatch be it missing entirely or marked as optional when it can't be
      • steep raises InsufficientKeywordArguments
    • given a value typing mismatch (i.e. there's a String where there should be an Integer)
      • steep raises an error indicating the value types don't satisfy the keyrest operator.
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

No branches or pull requests

1 participant