tapioca 0.17.9 → 0.17.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/tapioca/commands/abstract_dsl.rb +21 -2
  4. data/lib/tapioca/commands/abstract_gem.rb +20 -1
  5. data/lib/tapioca/commands/annotations.rb +7 -1
  6. data/lib/tapioca/commands/check_shims.rb +9 -1
  7. data/lib/tapioca/dsl/compiler.rb +17 -12
  8. data/lib/tapioca/dsl/compilers/aasm.rb +2 -2
  9. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -2
  10. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
  11. data/lib/tapioca/dsl/compilers/action_text.rb +1 -1
  12. data/lib/tapioca/dsl/compilers/active_job.rb +1 -1
  13. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
  14. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -1
  15. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -1
  16. data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -1
  17. data/lib/tapioca/dsl/compilers/active_record_columns.rb +8 -2
  18. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -1
  19. data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -1
  20. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
  21. data/lib/tapioca/dsl/compilers/active_record_relations.rb +12 -81
  22. data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -1
  23. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -1
  24. data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -1
  25. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -1
  26. data/lib/tapioca/dsl/compilers/active_resource.rb +1 -1
  27. data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
  28. data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -6
  29. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
  30. data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -1
  31. data/lib/tapioca/dsl/compilers/config.rb +2 -2
  32. data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -1
  33. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
  34. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -1
  35. data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -2
  36. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
  37. data/lib/tapioca/dsl/compilers/kredis.rb +1 -1
  38. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -2
  39. data/lib/tapioca/dsl/compilers/protobuf.rb +2 -2
  40. data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -1
  41. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
  42. data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -1
  43. data/lib/tapioca/dsl/compilers/state_machines.rb +2 -2
  44. data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -7
  45. data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +3 -1
  46. data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +18 -3
  47. data/lib/tapioca/dsl/pipeline.rb +25 -11
  48. data/lib/tapioca/gem/events.rb +15 -8
  49. data/lib/tapioca/gem/listeners/methods.rb +19 -7
  50. data/lib/tapioca/gem/listeners/mixins.rb +3 -3
  51. data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
  52. data/lib/tapioca/gem/pipeline.rb +25 -18
  53. data/lib/tapioca/gemfile.rb +1 -1
  54. data/lib/tapioca/helpers/config_helper.rb +5 -1
  55. data/lib/tapioca/helpers/rbi_files_helper.rb +8 -1
  56. data/lib/tapioca/loaders/gem.rb +14 -2
  57. data/lib/tapioca/rbi_ext/model.rb +9 -2
  58. data/lib/tapioca/repo_index.rb +1 -1
  59. data/lib/tapioca/runtime/attached_class_of_32.rb +1 -1
  60. data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -1
  61. data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
  62. data/lib/tapioca/runtime/generic_type_registry.rb +8 -8
  63. data/lib/tapioca/runtime/reflection.rb +19 -19
  64. data/lib/tapioca/runtime/trackers/constant_definition.rb +3 -3
  65. data/lib/tapioca/runtime/trackers/method_definition.rb +4 -4
  66. data/lib/tapioca/runtime/trackers/mixin.rb +5 -5
  67. data/lib/tapioca/runtime/trackers/required_ancestor.rb +2 -2
  68. data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
  69. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -1
  70. data/lib/tapioca/static/requires_compiler.rb +1 -1
  71. data/lib/tapioca/version.rb +1 -1
  72. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3668f1f1916b284b762a3ed370a2f658b2edd25d1c0c44be37fd7ca321be9200
4
- data.tar.gz: ce3540ff4aaebab9b9e506c4192ffdee93ef17c09b2399fb114d2b735fbf0b0e
3
+ metadata.gz: fd0aedb9a8295fc96a30b43e9a3da1f84bebdf3f97bb2fbd1fd99375fdad6fc1
4
+ data.tar.gz: 2c649b047df9cb012f7ed8502c9206e419e70a6bc7c1d2d07785aaad51af649e
5
5
  SHA512:
6
- metadata.gz: 648c2bd8e7ef7f14c0bce4736ea47636c043a5ee1e529e676569c85f398b1380838631fab7146439162491523446ac40c112fb8247ca55402947d372b235f5c7
7
- data.tar.gz: 11370dc255bf5e5508139480e4e9def8a51f145de3574c1f4dd17ad72572f1b64b30d0d876244426542b35d1e639d18662719f47137049d5aaac1fb6bdc7d5c6
6
+ metadata.gz: d1fe2a59d4570b065179f64d6de4e6bd27f494b2c23545c4a2ccf64a9cf33383ca5fd99a5eaf1ac3d93ff720b68780504b09beb501ad5567c6ea5c917d9004fe
7
+ data.tar.gz: '08514a0edef06b920cc2a07493f86f9a428e33554d1509210cfc4a0d044735303043efceb1a14f3ce2d18b29d4693bcd8e36a9153c4c4c836aa0fcbacd5110ef'
data/README.md CHANGED
@@ -673,7 +673,7 @@ module Tapioca
673
673
 
674
674
  ConstantType = type_member {{ fixed: T.class_of(Encryptable) }}
675
675
 
676
- sig { override.returns(T::Enumerable[Module]) }
676
+ sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
677
677
  def self.gather_constants
678
678
  # Collect all the classes that include Encryptable
679
679
  all_classes.select { |c| c < ::Encryptable }
@@ -806,7 +806,7 @@ module Tapioca
806
806
 
807
807
  ConstantType = type_member {{ fixed: T.class_of(Encryptable) }}
808
808
 
809
- sig { override.returns(T::Enumerable[Module]) }
809
+ sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
810
810
  def self.gather_constants
811
811
  # Collect all the classes that include Encryptable
812
812
  all_classes.select { |c| c < ::Encryptable }
@@ -8,7 +8,26 @@ module Tapioca
8
8
  include SorbetHelper
9
9
  include RBIFilesHelper
10
10
 
11
- #: (requested_constants: Array[String], requested_paths: Array[Pathname], outpath: Pathname, only: Array[String], exclude: Array[String], file_header: bool, tapioca_path: String, ?skip_constant: Array[String], ?quiet: bool, ?verbose: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?gem_dir: String, ?rbi_formatter: RBIFormatter, ?app_root: String, ?halt_upon_load_error: bool, ?compiler_options: Hash[String, untyped], ?lsp_addon: bool) -> void
11
+ #: (
12
+ #| requested_constants: Array[String],
13
+ #| requested_paths: Array[Pathname],
14
+ #| outpath: Pathname,
15
+ #| only: Array[String],
16
+ #| exclude: Array[String],
17
+ #| file_header: bool,
18
+ #| tapioca_path: String,
19
+ #| ?skip_constant: Array[String],
20
+ #| ?quiet: bool,
21
+ #| ?verbose: bool,
22
+ #| ?number_of_workers: Integer?,
23
+ #| ?auto_strictness: bool,
24
+ #| ?gem_dir: String,
25
+ #| ?rbi_formatter: RBIFormatter,
26
+ #| ?app_root: String,
27
+ #| ?halt_upon_load_error: bool,
28
+ #| ?compiler_options: Hash[String, untyped],
29
+ #| ?lsp_addon: bool
30
+ #| ) -> void
12
31
  def initialize(
13
32
  requested_constants:,
14
33
  requested_paths:,
@@ -143,7 +162,7 @@ module Tapioca
143
162
  filenames.to_set
144
163
  end
145
164
 
146
- #: (Array[String] constant_names, ?ignore_missing: bool) -> Array[Module]
165
+ #: (Array[String] constant_names, ?ignore_missing: bool) -> Array[T::Module[top]]
147
166
  def constantize(constant_names, ignore_missing: false)
148
167
  constant_map = constant_names.to_h do |name|
149
168
  [name, Object.const_get(name)]
@@ -8,7 +8,26 @@ module Tapioca
8
8
  include SorbetHelper
9
9
  include RBIFilesHelper
10
10
 
11
- #: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?, ?verbose: bool?) -> void
11
+ #: (
12
+ #| gem_names: Array[String],
13
+ #| exclude: Array[String],
14
+ #| include_dependencies: bool,
15
+ #| prerequire: String?,
16
+ #| postrequire: String,
17
+ #| typed_overrides: Hash[String, String],
18
+ #| outpath: Pathname,
19
+ #| file_header: bool,
20
+ #| include_doc: bool,
21
+ #| include_loc: bool,
22
+ #| include_exported_rbis: bool,
23
+ #| ?number_of_workers: Integer?,
24
+ #| ?auto_strictness: bool,
25
+ #| ?dsl_dir: String,
26
+ #| ?rbi_formatter: RBIFormatter,
27
+ #| ?halt_upon_load_error: bool,
28
+ #| ?lsp_addon: bool?,
29
+ #| ?verbose: bool?
30
+ #| ) -> void
12
31
  def initialize(
13
32
  gem_names:,
14
33
  exclude:,
@@ -6,7 +6,13 @@ module Tapioca
6
6
  class Annotations < CommandWithoutTracker
7
7
  extend T::Sig
8
8
 
9
- #: (central_repo_root_uris: Array[String], ?auth: String?, ?netrc_file: String?, ?central_repo_index_path: String, ?typed_overrides: Hash[String, String]) -> void
9
+ #: (
10
+ #| central_repo_root_uris: Array[String],
11
+ #| ?auth: String?,
12
+ #| ?netrc_file: String?,
13
+ #| ?central_repo_index_path: String,
14
+ #| ?typed_overrides: Hash[String, String]
15
+ #| ) -> void
10
16
  def initialize(
11
17
  central_repo_root_uris:,
12
18
  auth: nil,
@@ -8,7 +8,15 @@ module Tapioca
8
8
  include SorbetHelper
9
9
  include RBIFilesHelper
10
10
 
11
- #: (gem_rbi_dir: String, dsl_rbi_dir: String, annotations_rbi_dir: String, shim_rbi_dir: String, todo_rbi_file: String, payload: bool, number_of_workers: Integer?) -> void
11
+ #: (
12
+ #| gem_rbi_dir: String,
13
+ #| dsl_rbi_dir: String,
14
+ #| annotations_rbi_dir: String,
15
+ #| shim_rbi_dir: String,
16
+ #| todo_rbi_file: String,
17
+ #| payload: bool,
18
+ #| number_of_workers: Integer?
19
+ #| ) -> void
12
20
  def initialize(
13
21
  gem_rbi_dir:,
14
22
  dsl_rbi_dir:,
@@ -4,7 +4,7 @@
4
4
  module Tapioca
5
5
  module Dsl
6
6
  # @abstract
7
- #: [ConstantType < Module]
7
+ #: [ConstantType < T::Module[top]]
8
8
  class Compiler
9
9
  extend T::Sig
10
10
 
@@ -21,26 +21,26 @@ module Tapioca
21
21
  #: Hash[String, untyped]
22
22
  attr_reader :options
23
23
 
24
- @@requested_constants = [] #: Array[Module] # rubocop:disable Style/ClassVars
24
+ @@requested_constants = [] #: Array[T::Module[top]] # rubocop:disable Style/ClassVars
25
25
 
26
26
  class << self
27
27
  extend T::Sig
28
28
 
29
- #: (Module constant) -> bool
29
+ #: (T::Module[top] constant) -> bool
30
30
  def handles?(constant)
31
31
  processable_constants.include?(constant)
32
32
  end
33
33
 
34
34
  # @abstract
35
- #: -> T::Enumerable[Module]
35
+ #: -> Enumerable[T::Module[top]]
36
36
  def gather_constants = raise NotImplementedError, "Abstract method called"
37
37
 
38
- #: -> Set[Module]
38
+ #: -> Set[T::Module[top]]
39
39
  def processable_constants
40
- @processable_constants ||= T::Set[Module].new.compare_by_identity.merge(gather_constants) #: Set[Module]?
40
+ @processable_constants ||= T::Set[T::Module[T.anything]].new.compare_by_identity.merge(gather_constants) #: Set[T::Module[top]]?
41
41
  end
42
42
 
43
- #: (Array[Module] constants) -> void
43
+ #: (Array[T::Module[top]] constants) -> void
44
44
  def requested_constants=(constants)
45
45
  @@requested_constants = constants # rubocop:disable Style/ClassVars
46
46
  end
@@ -68,22 +68,27 @@ module Tapioca
68
68
  end
69
69
  end
70
70
 
71
- #: -> T::Enumerable[Class[top]]
71
+ #: -> Enumerable[Class[top]]
72
72
  def all_classes
73
- @all_classes ||= all_modules.grep(Class).freeze #: T::Enumerable[Class[top]]?
73
+ @all_classes ||= all_modules.grep(Class).freeze #: Enumerable[Class[top]]?
74
74
  end
75
75
 
76
- #: -> T::Enumerable[Module]
76
+ #: -> Enumerable[T::Module[top]]
77
77
  def all_modules
78
78
  @all_modules ||= if @@requested_constants.any?
79
79
  @@requested_constants.grep(Module)
80
80
  else
81
81
  ObjectSpace.each_object(Module).to_a
82
- end.freeze #: T::Enumerable[Module]?
82
+ end.freeze #: Enumerable[T::Module[top]]?
83
83
  end
84
84
  end
85
85
 
86
- #: (Tapioca::Dsl::Pipeline pipeline, RBI::Tree root, ConstantType constant, ?Hash[String, untyped] options) -> void
86
+ #: (
87
+ #| Tapioca::Dsl::Pipeline pipeline,
88
+ #| RBI::Tree root,
89
+ #| ConstantType constant,
90
+ #| ?Hash[String, untyped] options
91
+ #| ) -> void
87
92
  def initialize(pipeline, root, constant, options = {})
88
93
  @pipeline = pipeline
89
94
  @root = root
@@ -203,9 +203,9 @@ module Tapioca
203
203
  extend T::Sig
204
204
 
205
205
  # @override
206
- #: -> T::Enumerable[Module]
206
+ #: -> Enumerable[T::Module[top]]
207
207
  def gather_constants
208
- T.cast(ObjectSpace.each_object(::AASM::ClassMethods), T::Enumerable[Module])
208
+ T.cast(ObjectSpace.each_object(::AASM::ClassMethods), T::Enumerable[T::Module[T.anything]])
209
209
  end
210
210
  end
211
211
  end
@@ -121,7 +121,7 @@ module Tapioca
121
121
  extend T::Sig
122
122
 
123
123
  # @override
124
- #: -> T::Enumerable[Module]
124
+ #: -> Enumerable[T::Module[top]]
125
125
  def gather_constants
126
126
  descendants_of(::ActionController::Base).select(&:name).select do |klass|
127
127
  klass.const_defined?(:HelperMethods, false)
@@ -152,7 +152,7 @@ module Tapioca
152
152
  )
153
153
  end
154
154
 
155
- #: (Module mod) -> Array[String]
155
+ #: (T::Module[top] mod) -> Array[String]
156
156
  def gather_includes(mod)
157
157
  mod.ancestors
158
158
  .reject { |ancestor| ancestor.is_a?(Class) || ancestor == mod || name_of(ancestor).nil? }
@@ -54,7 +54,7 @@ module Tapioca
54
54
  extend T::Sig
55
55
 
56
56
  # @override
57
- #: -> T::Enumerable[Module]
57
+ #: -> Enumerable[T::Module[top]]
58
58
  def gather_constants
59
59
  descendants_of(::ActionMailer::Base).reject(&:abstract?)
60
60
  end
@@ -84,7 +84,7 @@ module Tapioca
84
84
  end
85
85
 
86
86
  # @override
87
- #: -> T::Enumerable[Module]
87
+ #: -> Enumerable[T::Module[top]]
88
88
  def gather_constants
89
89
  descendants_of(::ActiveRecord::Base)
90
90
  .reject(&:abstract_class?)
@@ -88,7 +88,7 @@ module Tapioca
88
88
  extend T::Sig
89
89
 
90
90
  # @override
91
- #: -> T::Enumerable[Module]
91
+ #: -> Enumerable[T::Module[top]]
92
92
  def gather_constants
93
93
  descendants_of(::ActiveJob::Base)
94
94
  end
@@ -63,7 +63,7 @@ module Tapioca
63
63
  extend T::Sig
64
64
 
65
65
  # @override
66
- #: -> T::Enumerable[Module]
66
+ #: -> Enumerable[T::Module[top]]
67
67
  def gather_constants
68
68
  all_classes.grep(::ActiveModel::Attributes::ClassMethods)
69
69
  end
@@ -93,7 +93,7 @@ module Tapioca
93
93
  extend T::Sig
94
94
 
95
95
  # @override
96
- #: -> T::Enumerable[Module]
96
+ #: -> Enumerable[T::Module[top]]
97
97
  def gather_constants
98
98
  # In some versions of Rails 8.1, `ActiveModel::SecurePassword` uses `Numeric#minutes`
99
99
  # which isn't explicitly required in the gem, and it might not be loaded already.
@@ -46,7 +46,7 @@ module Tapioca
46
46
 
47
47
  class << self
48
48
  # @override
49
- #: -> T::Enumerable[Module]
49
+ #: -> Enumerable[T::Module[top]]
50
50
  def gather_constants
51
51
  # Collect all the classes that include ActiveModel::Validations
52
52
  all_classes.select { |c| ActiveModel::Validations > c }
@@ -141,7 +141,7 @@ module Tapioca
141
141
  extend T::Sig
142
142
 
143
143
  # @override
144
- #: -> T::Enumerable[Module]
144
+ #: -> Enumerable[T::Module[top]]
145
145
  def gather_constants
146
146
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
147
147
  end
@@ -166,7 +166,7 @@ module Tapioca
166
166
  extend T::Sig
167
167
 
168
168
  # @override
169
- #: -> T::Enumerable[Module]
169
+ #: -> Enumerable[T::Module[top]]
170
170
  def gather_constants
171
171
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
172
172
  end
@@ -189,7 +189,13 @@ module Tapioca
189
189
  )
190
190
  end
191
191
 
192
- #: (RBI::Scope klass, String name, Array[String]? methods_to_add, ?return_type: String, ?parameters: Array[RBI::TypedParam]) -> void
192
+ #: (
193
+ #| RBI::Scope klass,
194
+ #| String name,
195
+ #| Array[String]? methods_to_add,
196
+ #| ?return_type: String,
197
+ #| ?parameters: Array[RBI::TypedParam]
198
+ #| ) -> void
193
199
  def add_method(klass, name, methods_to_add, return_type: "void", parameters: [])
194
200
  klass.create_method(
195
201
  name,
@@ -91,7 +91,7 @@ module Tapioca
91
91
  extend T::Sig
92
92
 
93
93
  # @override
94
- #: -> T::Enumerable[Module]
94
+ #: -> Enumerable[T::Module[top]]
95
95
  def gather_constants
96
96
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
97
97
  end
@@ -78,7 +78,7 @@ module Tapioca
78
78
  extend T::Sig
79
79
 
80
80
  # @override
81
- #: -> T::Enumerable[Module]
81
+ #: -> Enumerable[T::Module[top]]
82
82
  def gather_constants
83
83
  descendants_of(::ActiveRecord::Base)
84
84
  end
@@ -62,7 +62,7 @@ module Tapioca
62
62
  extend T::Sig
63
63
 
64
64
  # @override
65
- #: -> T::Enumerable[Module]
65
+ #: -> Enumerable[T::Module[top]]
66
66
  def gather_constants
67
67
  return [] unless defined?(Rails.application) && Rails.application
68
68
 
@@ -184,7 +184,7 @@ module Tapioca
184
184
  extend T::Sig
185
185
 
186
186
  # @override
187
- #: -> T::Enumerable[Module]
187
+ #: -> Enumerable[T::Module[top]]
188
188
  def gather_constants
189
189
  ActiveRecord::Base.descendants.reject(&:abstract_class?)
190
190
  end
@@ -604,47 +604,9 @@ module Tapioca
604
604
 
605
605
  #: -> void
606
606
  def create_association_relation_methods
607
- returning_type = "T.nilable(T.any(T::Array[Symbol], FalseClass))"
608
- unique_by_type = "T.nilable(T.any(T::Array[Symbol], Symbol))"
609
-
610
- ASSOCIATION_METHODS.each do |method_name|
611
- case method_name
612
- when :insert_all, :insert_all!, :upsert_all
613
- parameters = [
614
- create_param("attributes", type: "T::Array[Hash]"),
615
- create_kw_opt_param("returning", type: returning_type, default: "nil"),
616
- ]
617
-
618
- # Bang methods don't have the `unique_by` parameter
619
- unless bang_method?(method_name)
620
- parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
621
- end
622
-
623
- association_relation_methods_module.create_method(
624
- method_name.to_s,
625
- parameters: parameters,
626
- return_type: "ActiveRecord::Result",
627
- )
628
- when :insert, :insert!, :upsert
629
- parameters = [
630
- create_param("attributes", type: "Hash"),
631
- create_kw_opt_param("returning", type: returning_type, default: "nil"),
632
- ]
633
-
634
- # Bang methods don't have the `unique_by` parameter
635
- unless bang_method?(method_name)
636
- parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
637
- end
638
-
639
- association_relation_methods_module.create_method(
640
- method_name.to_s,
641
- parameters: parameters,
642
- return_type: "ActiveRecord::Result",
643
- )
644
- when :proxy_association
645
- # skip - private method
646
- end
647
- end
607
+ # skips insert/upsert methods - these methods' signatures aren't model-specific and don't need to be generated dynamically
608
+ # also skips proxy_association method - it's a private method
609
+ # but there could be other association methods that we need to generate
648
610
  end
649
611
 
650
612
  #: -> void
@@ -953,44 +915,8 @@ module Tapioca
953
915
  sig.return_type = constant_name
954
916
  end
955
917
  end
956
- when :insert_all, :insert_all!, :upsert_all # insert all methods
957
- returning_type = "T.nilable(T.any(T::Array[Symbol], FalseClass))"
958
- unique_by_type = "T.nilable(T.any(T::Array[Symbol], Symbol))"
959
-
960
- parameters = [
961
- create_param("attributes", type: "T::Array[Hash]"),
962
- create_kw_opt_param("returning", type: returning_type, default: "nil"),
963
- ]
964
-
965
- # Bang methods don't have the `unique_by` parameter
966
- unless bang_method?(method_name)
967
- parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
968
- end
969
-
970
- common_relation_methods_module.create_method(
971
- method_name.to_s,
972
- parameters: parameters,
973
- return_type: "ActiveRecord::Result",
974
- )
975
- when :insert, :insert!, :upsert # insert methods
976
- returning_type = "T.nilable(T.any(T::Array[Symbol], FalseClass))"
977
- unique_by_type = "T.nilable(T.any(T::Array[Symbol], Symbol))"
978
-
979
- parameters = [
980
- create_param("attributes", type: "Hash"),
981
- create_kw_opt_param("returning", type: returning_type, default: "nil"),
982
- ]
983
-
984
- # Bang methods don't have the `unique_by` parameter
985
- unless bang_method?(method_name)
986
- parameters << create_kw_opt_param("unique_by", type: unique_by_type, default: "nil")
987
- end
988
-
989
- common_relation_methods_module.create_method(
990
- method_name.to_s,
991
- parameters: parameters,
992
- return_type: "ActiveRecord::Result",
993
- )
918
+ when :insert_all, :insert_all!, :upsert_all, :insert, :insert!, :upsert # insert methods
919
+ # skip - these methods' signatures aren't model-specific and don't need to be generated dynamically
994
920
  when :delete, :destroy
995
921
  # For these cases, it is valid to pass the above kind of things, but also:
996
922
  # - a model identifier, which can be:
@@ -1107,7 +1033,12 @@ module Tapioca
1107
1033
  end
1108
1034
  end
1109
1035
 
1110
- #: ((Symbol | String) name, ?parameters: Array[RBI::TypedParam], ?relation_return_type: String, ?association_return_type: String) -> void
1036
+ #: (
1037
+ #| (Symbol | String) name,
1038
+ #| ?parameters: Array[RBI::TypedParam],
1039
+ #| ?relation_return_type: String,
1040
+ #| ?association_return_type: String
1041
+ #| ) -> void
1111
1042
  def create_relation_method(
1112
1043
  name,
1113
1044
  parameters: [],
@@ -78,7 +78,7 @@ module Tapioca
78
78
 
79
79
  class << self
80
80
  # @override
81
- #: -> T::Enumerable[Module]
81
+ #: -> Enumerable[T::Module[top]]
82
82
  def gather_constants
83
83
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
84
84
  end
@@ -60,7 +60,7 @@ module Tapioca
60
60
  extend T::Sig
61
61
 
62
62
  # @override
63
- #: -> T::Enumerable[Module]
63
+ #: -> Enumerable[T::Module[top]]
64
64
  def gather_constants
65
65
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
66
66
  end
@@ -135,7 +135,7 @@ module Tapioca
135
135
  extend T::Sig
136
136
 
137
137
  # @override
138
- #: -> T::Enumerable[Module]
138
+ #: -> Enumerable[T::Module[top]]
139
139
  def gather_constants
140
140
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
141
141
  end
@@ -111,7 +111,7 @@ module Tapioca
111
111
  extend T::Sig
112
112
 
113
113
  # @override
114
- #: -> T::Enumerable[Module]
114
+ #: -> Enumerable[T::Module[top]]
115
115
  def gather_constants
116
116
  descendants_of(::ActiveRecord::Base).select do |klass|
117
117
  klass.include?(ActiveRecord::TypedStore::Behavior)
@@ -74,7 +74,7 @@ module Tapioca
74
74
  extend T::Sig
75
75
 
76
76
  # @override
77
- #: -> T::Enumerable[Module]
77
+ #: -> Enumerable[T::Module[top]]
78
78
  def gather_constants
79
79
  descendants_of(::ActiveResource::Base)
80
80
  end
@@ -38,7 +38,7 @@ module Tapioca
38
38
  # def photo=(attachable); end
39
39
  # end
40
40
  # ~~~
41
- #: [ConstantType = (Module & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
41
+ #: [ConstantType = (T::Module[top] & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
42
42
  class ActiveStorage < Compiler
43
43
  extend T::Sig
44
44
 
@@ -68,7 +68,7 @@ module Tapioca
68
68
  extend T::Sig
69
69
 
70
70
  # @override
71
- #: -> T::Enumerable[Module]
71
+ #: -> Enumerable[T::Module[top]]
72
72
  def gather_constants
73
73
  descendants_of(::ActiveRecord::Base)
74
74
  .reject(&:abstract_class?)
@@ -37,7 +37,7 @@ module Tapioca
37
37
  # mixes_in_class_methods(::Foo::ClassMethods)
38
38
  # end
39
39
  # ~~~
40
- #: [ConstantType = Module]
40
+ #: [ConstantType = T::Module[top]]
41
41
  class ActiveSupportConcern < Compiler
42
42
  extend T::Sig
43
43
 
@@ -65,7 +65,7 @@ module Tapioca
65
65
  extend T::Sig
66
66
 
67
67
  # @override
68
- #: -> T::Enumerable[Module]
68
+ #: -> Enumerable[T::Module[top]]
69
69
  def gather_constants
70
70
  all_modules.select do |mod|
71
71
  name_of(mod) && # i.e. not anonymous
@@ -76,10 +76,10 @@ module Tapioca
76
76
  end
77
77
 
78
78
  # Returns true when `mod` includes other concerns
79
- #: (Module mod) -> bool
79
+ #: (T::Module[top] mod) -> bool
80
80
  def has_dependencies?(mod) = dependencies_of(mod).any?
81
81
 
82
- #: (Module concern) -> Array[Module]
82
+ #: (T::Module[top] concern) -> Array[T::Module[top]]
83
83
  def dependencies_of(concern)
84
84
  concern.instance_variable_get(:@_dependencies) || []
85
85
  end
@@ -87,12 +87,12 @@ module Tapioca
87
87
 
88
88
  private
89
89
 
90
- #: (Module concern) -> Array[Module]
90
+ #: (T::Module[top] concern) -> Array[T::Module[top]]
91
91
  def dependencies_of(concern)
92
92
  self.class.dependencies_of(concern)
93
93
  end
94
94
 
95
- #: (?Module concern) -> Array[Module]
95
+ #: (?T::Module[top] concern) -> Array[T::Module[top]]
96
96
  def linearized_dependencies(concern = constant)
97
97
  # Grab all the dependencies of the concern
98
98
  dependencies = dependencies_of(concern)
@@ -97,7 +97,7 @@ module Tapioca
97
97
  extend T::Sig
98
98
 
99
99
  # @override
100
- #: -> T::Enumerable[Module]
100
+ #: -> Enumerable[T::Module[top]]
101
101
  def gather_constants
102
102
  descendants_of(::ActiveSupport::CurrentAttributes)
103
103
  end
@@ -58,7 +58,7 @@ module Tapioca
58
58
  extend T::Sig
59
59
 
60
60
  # @override
61
- #: -> T::Enumerable[Module]
61
+ #: -> Enumerable[T::Module[top]]
62
62
  def gather_constants
63
63
  [::Time]
64
64
  end
@@ -40,7 +40,7 @@ module Tapioca
40
40
  # def github=(value); end
41
41
  # end
42
42
  # ```
43
- #: [ConstantType = Module]
43
+ #: [ConstantType = T::Module[top]]
44
44
  class Config < Compiler
45
45
  extend T::Sig
46
46
 
@@ -96,7 +96,7 @@ module Tapioca
96
96
  extend T::Sig
97
97
 
98
98
  # @override
99
- #: -> T::Enumerable[Module]
99
+ #: -> Enumerable[T::Module[top]]
100
100
  def gather_constants
101
101
  name = ::Config.const_name
102
102
  return [] unless Object.const_defined?(name)
@@ -88,7 +88,7 @@ module Tapioca
88
88
  extend T::Sig
89
89
 
90
90
  # @override
91
- #: -> T::Enumerable[Module]
91
+ #: -> Enumerable[T::Module[top]]
92
92
  def gather_constants
93
93
  descendants_of(::FrozenRecord::Base).reject(&:abstract_class?)
94
94
  end