Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
support newer type_member syntax with sorbet 0.5.9892+ (#504)
Browse files Browse the repository at this point in the history
* bump sorbet dependency to support newer type_member syntax

* regenerate Gemfile.lock in spec/support via bundle update

* use new type_member format while generating RBIs

* update test data to use new syntax

* update sorbet-typed to use new syntax
  • Loading branch information
ashkulz committed Apr 19, 2022
1 parent c455c5d commit 05714e4
Show file tree
Hide file tree
Showing 83 changed files with 529 additions and 505 deletions.
6 changes: 3 additions & 3 deletions lib/sorbet-rails/active_record_rbi_formatter.rb
Expand Up @@ -40,7 +40,7 @@ def generate_active_record_relation_rbi
class_rbi.create_include("Enumerable")
# class_rbi.create_constant(
# "Elem",
# value: "type_member(fixed: T.untyped)",
# value: "type_member {{fixed: T.untyped}}",
# )

create_elem_specific_query_methods(class_rbi, type: 'Elem', class_method: false)
Expand Down Expand Up @@ -75,7 +75,7 @@ def generate_active_record_relation_rbi
parlour.root.create_class("ActiveRecord::AssociationRelation", superclass: "ActiveRecord::Relation") do |class_rbi|
class_rbi.create_constant(
"Elem",
value: "type_member(fixed: T.untyped)",
value: "type_member {{fixed: T.untyped}}",
)

# Ideally we shouldn't need to define these since this class inherits from
Expand Down Expand Up @@ -110,7 +110,7 @@ def generate_active_record_relation_rbi
parlour.root.create_class("ActiveRecord::Associations::CollectionProxy", superclass: "ActiveRecord::Relation") do |class_rbi|
class_rbi.create_constant(
"Elem",
value: "type_member(fixed: T.untyped)",
value: "type_member {{fixed: T.untyped}}",
)

# This _should_ work which would let us remove it from the enumerable_collections
Expand Down
6 changes: 3 additions & 3 deletions lib/sorbet-rails/model_rbi_formatter.rb
Expand Up @@ -80,7 +80,7 @@ def generate_base_rbi(root)
model_relation_rbi.create_include(self.model_query_methods_returning_relation_module_name)
model_relation_rbi.create_constant(
"Elem",
value: "type_member(fixed: #{model_class_name})",
value: "type_member {{fixed: #{model_class_name}}}",
)

model_assoc_relation_rbi = root.create_class(
Expand All @@ -90,7 +90,7 @@ def generate_base_rbi(root)
model_assoc_relation_rbi.create_include(self.model_query_methods_returning_assoc_relation_module_name)
model_assoc_relation_rbi.create_constant(
"Elem",
value: "type_member(fixed: #{model_class_name})",
value: "type_member {{fixed: #{model_class_name}}}",
)

collection_proxy_rbi = root.create_class(
Expand All @@ -100,7 +100,7 @@ def generate_base_rbi(root)
collection_proxy_rbi.create_include(self.model_query_methods_returning_assoc_relation_module_name)
collection_proxy_rbi.create_constant(
"Elem",
value: "type_member(fixed: #{self.model_class_name})",
value: "type_member {{fixed: #{self.model_class_name}}}",
)

model_rbi = root.create_class(
Expand Down
2 changes: 1 addition & 1 deletion sorbet-rails.gemspec
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
end

s.add_dependency 'parlour', '>= 4.0.1'
s.add_dependency 'sorbet-runtime', '>= 0.5'
s.add_dependency 'sorbet-runtime', '>= 0.5.9892'
s.add_dependency 'sorbet-coerce', '>= 0.2.6'
s.add_dependency 'method_source', '>= 0.9.2'
s.add_dependency 'parser', '>= 2.7'
Expand Down
Expand Up @@ -568,7 +568,7 @@ ActiveModel::Validations::NumericalityValidator::RESERVED_OPTIONS = T.let(T.unsa

class ActiveModel::Errors
include Enumerable
Elem = type_member(fixed: T.untyped)
Elem = type_member {{fixed: T.untyped}}

sig { params(key: T.any(String, Symbol)).returns(T::Array[String]) }
def [](key); end
Expand Down
4 changes: 2 additions & 2 deletions sorbet/rbi/sorbet-typed/lib/activerecord/all/activerecord.rbi
Expand Up @@ -979,7 +979,7 @@ end

class ActiveRecord::Result
include(::Enumerable)
Elem = type_member(fixed: T.untyped)
Elem = type_member {{fixed: T.untyped}}
end

ActiveRecord::Type::BigInteger = ActiveModel::Type::BigInteger
Expand Down Expand Up @@ -1610,7 +1610,7 @@ end
ActiveRecord::LogSubscriber::IGNORE_PAYLOAD_NAMES = T.let(T.unsafe(nil), T::Array[T.untyped])

class ActiveRecord::Relation
Elem = type_member(fixed: T.untyped)
Elem = type_member {{fixed: T.untyped}}

sig { returns(Integer) }
def delete_all; end
Expand Down
30 changes: 15 additions & 15 deletions sorbet/rbi/sorbet-typed/lib/activesupport/all/activesupport.rbi
Expand Up @@ -550,9 +550,9 @@ module ActiveSupport::Inflector
end

class ActiveSupport::InheritableOptions < ::ActiveSupport::OrderedOptions
K = type_member(fixed: T.untyped)
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.untyped}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}

def initialize(parent = T.unsafe(nil)); end

Expand Down Expand Up @@ -1767,9 +1767,9 @@ end
module ActiveSupport::Configurable::ClassMethods; end

class ActiveSupport::Configurable::Configuration < ::ActiveSupport::InheritableOptions
K = type_member(fixed: T.untyped)
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.untyped}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}
end

ActiveSupport::Deprecation::DEFAULT_BEHAVIORS = T.let(T.unsafe(nil), T::Hash[T.untyped, T.untyped])
Expand All @@ -1786,9 +1786,9 @@ class ActiveSupport::DeprecationException < ::StandardError
end

class ActiveSupport::HashWithIndifferentAccess < Hash
K = type_member(fixed: T.any(String, Symbol))
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.any(String, Symbol)}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}
end

ActiveSupport::JSON::DATETIME_REGEX = T.let(T.unsafe(nil), Regexp)
Expand Down Expand Up @@ -1822,15 +1822,15 @@ ActiveSupport::Multibyte::Unicode::NORMALIZATION_FORM_ALIASES = T.let(T.unsafe(n
ActiveSupport::Multibyte::Unicode::UNICODE_VERSION = T.let(T.unsafe(nil), String)

class ActiveSupport::OrderedHash < ::Hash
K = type_member(fixed: T.untyped)
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.untyped}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}
end

class ActiveSupport::OrderedOptions < ::Hash
K = type_member(fixed: T.untyped)
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.untyped}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}
end

ActiveSupport::ParameterFilter::FILTERED = T.let(T.unsafe(nil), String)
Expand Down
6 changes: 3 additions & 3 deletions sorbet/rbi/sorbet-typed/lib/railties/all/railties.rbi
Expand Up @@ -40,9 +40,9 @@ end
Rails::Application::INITIAL_VARIABLES = T.let(T.unsafe(nil), T::Array[T.untyped])

class Rails::Application::NonSymbolAccessDeprecatedHash < ::ActiveSupport::HashWithIndifferentAccess
K = type_member(fixed: T.untyped)
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.untyped}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}
end

module Rails::Command::Behavior
Expand Down
12 changes: 6 additions & 6 deletions sorbet/rbi/sorbet-typed/lib/thor/all/thor.rbi
Expand Up @@ -361,7 +361,7 @@ module Thor::Base::ClassMethods
end

class Thor::Command < ::Struct
Elem = type_member(fixed: T.untyped)
Elem = type_member {{fixed: T.untyped}}

def initialize(name, description, long_description, usage, options = T.unsafe(nil)); end

Expand Down Expand Up @@ -392,9 +392,9 @@ module Thor::CoreExt
end

class Thor::CoreExt::HashWithIndifferentAccess < ::Hash
K = type_member(fixed: T.untyped)
V = type_member(fixed: T.untyped)
Elem = type_member(fixed: T.untyped)
K = type_member {{fixed: T.untyped}}
V = type_member {{fixed: T.untyped}}
Elem = type_member {{fixed: T.untyped}}

def initialize(hash = T.unsafe(nil)); end

Expand All @@ -420,7 +420,7 @@ end
Thor::Correctable = DidYouMean::Correctable

class Thor::DynamicCommand < ::Thor::Command
Elem = type_member(fixed: T.untyped)
Elem = type_member {{fixed: T.untyped}}

def initialize(name, options = T.unsafe(nil)); end

Expand Down Expand Up @@ -473,7 +473,7 @@ end
Thor::HELP_MAPPINGS = T.let(T.unsafe(nil), T::Array[T.untyped])

class Thor::HiddenCommand < ::Thor::Command
Elem = type_member(fixed: T.untyped)
Elem = type_member {{fixed: T.untyped}}

def hidden?; end
end
Expand Down

0 comments on commit 05714e4

Please sign in to comment.