tapioca 0.19.0 → 0.19.1
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.
- checksums.yaml +4 -4
- data/lib/tapioca/commands/abstract_dsl.rb +1 -1
- data/lib/tapioca/commands/check_shims.rb +3 -0
- data/lib/tapioca/commands/configure.rb +1 -0
- data/lib/tapioca/commands/todo.rb +8 -2
- data/lib/tapioca/dsl/compiler.rb +13 -13
- data/lib/tapioca/dsl/compilers/aasm.rb +1 -1
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -2
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
- data/lib/tapioca/dsl/compilers/action_text.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_job.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -6
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_support_environment_inquirer.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -1
- data/lib/tapioca/dsl/compilers/config.rb +2 -2
- data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -1
- data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -2
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/kredis.rb +1 -1
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -2
- data/lib/tapioca/dsl/compilers/protobuf.rb +1 -1
- data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -1
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
- data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -1
- data/lib/tapioca/dsl/compilers/state_machines.rb +2 -2
- data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -7
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +1 -1
- data/lib/tapioca/dsl/pipeline.rb +10 -10
- data/lib/tapioca/gem/events.rb +7 -7
- data/lib/tapioca/gem/listeners/methods.rb +8 -8
- data/lib/tapioca/gem/listeners/mixins.rb +3 -3
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +5 -3
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +18 -18
- data/lib/tapioca/helpers/sorbet_helper.rb +19 -0
- data/lib/tapioca/helpers/test/dsl_compiler.rb +2 -9
- data/lib/tapioca/internal.rb +1 -0
- data/lib/tapioca/rbi_ext/model.rb +8 -5
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
- data/lib/tapioca/runtime/generic_type_registry.rb +8 -8
- data/lib/tapioca/runtime/reflection.rb +20 -20
- data/lib/tapioca/runtime/trackers/constant_definition.rb +3 -3
- data/lib/tapioca/runtime/trackers/method_definition.rb +4 -4
- data/lib/tapioca/runtime/trackers/mixin.rb +5 -5
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +2 -2
- data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -1
- data/lib/tapioca/sorbet_ext/void_patch.rb +29 -0
- data/lib/tapioca/static/symbol_loader.rb +19 -1
- data/lib/tapioca/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d3606b2440f453c78a226d8beec0ce61673d416fa74dba7d0380cd31404feaa
|
|
4
|
+
data.tar.gz: c290cccb23e39c3423913357b187d74de382de4c818194676b206e0981f21c17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d655006a08405d41158b918625eadbcf7eec8b43da4c9077a7a9fe3ad94ee549865c27f0c66ae1fc0424afc8e6f30806e60f2ed661067264d920e52c6f04b70
|
|
7
|
+
data.tar.gz: 96c0d237d2fda54650e919d74fc838b5121b714dcb3a4d35d60836911895265b99b29848f399b7f529050d4c930c3669e52ca3787dfbf1671b883883f39b6bba
|
|
@@ -162,7 +162,7 @@ module Tapioca
|
|
|
162
162
|
filenames.to_set
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
-
#: (Array[String] constant_names, ?ignore_missing: bool) -> Array[
|
|
165
|
+
#: (Array[String] constant_names, ?ignore_missing: bool) -> Array[Module[top]]
|
|
166
166
|
def constantize(constant_names, ignore_missing: false)
|
|
167
167
|
constant_map = constant_names.to_h do |name|
|
|
168
168
|
[name, Object.const_get(name)]
|
|
@@ -53,6 +53,9 @@ module Tapioca
|
|
|
53
53
|
if @payload
|
|
54
54
|
Dir.mktmpdir do |dir|
|
|
55
55
|
payload_path = dir
|
|
56
|
+
|
|
57
|
+
# No need for `--stop-after`, because Sorbet exits immediately after dumping the payload.
|
|
58
|
+
# https://github.com/sorbet/sorbet/blob/41ae325/main/realmain.cc#L522-L552
|
|
56
59
|
result = sorbet("--no-config --print=payload-sources:#{payload_path}")
|
|
57
60
|
|
|
58
61
|
unless result.status
|
|
@@ -83,12 +83,18 @@ module Tapioca
|
|
|
83
83
|
#: -> Array[String]
|
|
84
84
|
def unresolved_constants
|
|
85
85
|
# Taken from https://github.com/sorbet/sorbet/blob/master/gems/sorbet/lib/todo-rbi.rb
|
|
86
|
-
sorbet(
|
|
86
|
+
sorbet(
|
|
87
|
+
"--print=missing-constants",
|
|
88
|
+
"--stop-after=resolver",
|
|
89
|
+
"--quiet",
|
|
90
|
+
"--stdout-hup-hack",
|
|
91
|
+
"--no-error-count",
|
|
92
|
+
)
|
|
87
93
|
.out
|
|
88
94
|
.strip
|
|
89
95
|
.each_line
|
|
90
96
|
.filter_map do |line|
|
|
91
|
-
next if line.include?("<")
|
|
97
|
+
next if line.include?("<") # Skip singleton classes like `#<Class:String>`
|
|
92
98
|
|
|
93
99
|
line.strip
|
|
94
100
|
.gsub(/T\.class_of\(([:\w]+)\)/, '\1') # Turn T.class_of(Foo)::Bar into Foo::Bar
|
data/lib/tapioca/dsl/compiler.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
module Tapioca
|
|
5
5
|
module Dsl
|
|
6
6
|
# @abstract
|
|
7
|
-
#: [ConstantType <
|
|
7
|
+
#: [ConstantType < Module[top]]
|
|
8
8
|
class Compiler
|
|
9
9
|
include RBIHelper
|
|
10
10
|
include Runtime::Reflection
|
|
@@ -19,24 +19,24 @@ module Tapioca
|
|
|
19
19
|
#: Hash[String, untyped]
|
|
20
20
|
attr_reader :options
|
|
21
21
|
|
|
22
|
-
@@requested_constants = [] #: Array[
|
|
22
|
+
@@requested_constants = [] #: Array[Module[top]] # rubocop:disable Style/ClassVars
|
|
23
23
|
|
|
24
24
|
class << self
|
|
25
|
-
#: (
|
|
25
|
+
#: (Module[top] constant) -> bool
|
|
26
26
|
def handles?(constant)
|
|
27
27
|
processable_constants.include?(constant)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# @abstract
|
|
31
|
-
#: -> Enumerable[
|
|
31
|
+
#: -> Enumerable[Module[top]]
|
|
32
32
|
def gather_constants = raise NotImplementedError, "Abstract method called"
|
|
33
33
|
|
|
34
|
-
#: -> Set[
|
|
34
|
+
#: -> Set[Module[top]]
|
|
35
35
|
def processable_constants
|
|
36
|
-
@processable_constants ||= T::Set[T::Module[T.anything]].new.compare_by_identity.merge(gather_constants) #: Set[
|
|
36
|
+
@processable_constants ||= T::Set[T::Module[T.anything]].new.compare_by_identity.merge(gather_constants) #: Set[Module[top]]?
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
#: (Array[
|
|
39
|
+
#: (Array[Module[top]] constants) -> void
|
|
40
40
|
def requested_constants=(constants)
|
|
41
41
|
@@requested_constants = constants # rubocop:disable Style/ClassVars
|
|
42
42
|
end
|
|
@@ -69,13 +69,13 @@ module Tapioca
|
|
|
69
69
|
@all_classes ||= all_modules.grep(Class).freeze #: Enumerable[Class[top]]?
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
#: -> Enumerable[
|
|
72
|
+
#: -> Enumerable[Module[top]]
|
|
73
73
|
def all_modules
|
|
74
74
|
@all_modules ||= if @@requested_constants.any?
|
|
75
75
|
@@requested_constants.grep(Module)
|
|
76
76
|
else
|
|
77
77
|
ObjectSpace.each_object(Module).to_a
|
|
78
|
-
end.freeze #: Enumerable[
|
|
78
|
+
end.freeze #: Enumerable[Module[top]]?
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -124,10 +124,12 @@ module Tapioca
|
|
|
124
124
|
signature.kwarg_types.each { |_, kwarg_type| params << kwarg_type.to_s }
|
|
125
125
|
|
|
126
126
|
# rest parameter type
|
|
127
|
-
|
|
127
|
+
rest_type = signature.rest_type
|
|
128
|
+
params << rest_type.to_s if rest_type
|
|
128
129
|
|
|
129
130
|
# keyrest parameter type
|
|
130
|
-
|
|
131
|
+
keyrest_type = signature.keyrest_type
|
|
132
|
+
params << keyrest_type.to_s if keyrest_type
|
|
131
133
|
|
|
132
134
|
# special case `.void` in a proc
|
|
133
135
|
unless signature.block_name.nil?
|
|
@@ -141,14 +143,12 @@ module Tapioca
|
|
|
141
143
|
def create_method_from_def(scope, method_def, class_method: false)
|
|
142
144
|
parameters = compile_method_parameters_to_rbi(method_def)
|
|
143
145
|
return_type = compile_method_return_type_to_rbi(method_def)
|
|
144
|
-
type_params = extract_type_parameters(parameters.map(&:type).push(return_type))
|
|
145
146
|
|
|
146
147
|
scope.create_method(
|
|
147
148
|
method_def.name.to_s,
|
|
148
149
|
parameters: parameters,
|
|
149
150
|
return_type: return_type,
|
|
150
151
|
class_method: class_method,
|
|
151
|
-
type_params: type_params,
|
|
152
152
|
)
|
|
153
153
|
end
|
|
154
154
|
|
|
@@ -202,7 +202,7 @@ module Tapioca
|
|
|
202
202
|
|
|
203
203
|
class << self
|
|
204
204
|
# @override
|
|
205
|
-
#: -> Enumerable[
|
|
205
|
+
#: -> Enumerable[Module[top]]
|
|
206
206
|
def gather_constants
|
|
207
207
|
T.cast(ObjectSpace.each_object(::AASM::ClassMethods), T::Enumerable[T::Module[T.anything]])
|
|
208
208
|
end
|
|
@@ -117,7 +117,7 @@ module Tapioca
|
|
|
117
117
|
|
|
118
118
|
class << self
|
|
119
119
|
# @override
|
|
120
|
-
#: -> Enumerable[
|
|
120
|
+
#: -> Enumerable[Module[top]]
|
|
121
121
|
def gather_constants
|
|
122
122
|
descendants_of(::ActionController::Base).select(&:name).select do |klass|
|
|
123
123
|
klass.const_defined?(:HelperMethods, false)
|
|
@@ -148,7 +148,7 @@ module Tapioca
|
|
|
148
148
|
)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
-
#: (
|
|
151
|
+
#: (Module[top] mod) -> Array[String]
|
|
152
152
|
def gather_includes(mod)
|
|
153
153
|
mod.ancestors
|
|
154
154
|
.reject { |ancestor| ancestor.is_a?(Class) || ancestor == mod || name_of(ancestor).nil? }
|
|
@@ -89,7 +89,7 @@ module Tapioca
|
|
|
89
89
|
|
|
90
90
|
class << self
|
|
91
91
|
# @override
|
|
92
|
-
#: -> Enumerable[
|
|
92
|
+
#: -> Enumerable[Module[top]]
|
|
93
93
|
def gather_constants
|
|
94
94
|
# In some versions of Rails 8.1, `ActiveModel::SecurePassword` uses `Numeric#minutes`
|
|
95
95
|
# which isn't explicitly required in the gem, and it might not be loaded already.
|
|
@@ -44,7 +44,7 @@ module Tapioca
|
|
|
44
44
|
class ActiveModelValidationsConfirmation < Compiler
|
|
45
45
|
class << self
|
|
46
46
|
# @override
|
|
47
|
-
#: -> Enumerable[
|
|
47
|
+
#: -> Enumerable[Module[top]]
|
|
48
48
|
def gather_constants
|
|
49
49
|
# Collect all the classes that include ActiveModel::Validations
|
|
50
50
|
all_classes.select { |c| ActiveModel::Validations > c }
|
|
@@ -107,7 +107,7 @@ module Tapioca
|
|
|
107
107
|
|
|
108
108
|
class << self
|
|
109
109
|
# @override
|
|
110
|
-
#: -> Enumerable[
|
|
110
|
+
#: -> Enumerable[Module[top]]
|
|
111
111
|
def gather_constants
|
|
112
112
|
descendants_of(::ActiveRecord::Base).select do |klass|
|
|
113
113
|
klass.include?(ActiveRecord::TypedStore::Behavior)
|
|
@@ -38,7 +38,7 @@ module Tapioca
|
|
|
38
38
|
# def photo=(attachable); end
|
|
39
39
|
# end
|
|
40
40
|
# ~~~
|
|
41
|
-
#: [ConstantType = (
|
|
41
|
+
#: [ConstantType = (Module[top] & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
|
|
42
42
|
class ActiveStorage < Compiler
|
|
43
43
|
# @override
|
|
44
44
|
#: -> void
|
|
@@ -64,7 +64,7 @@ module Tapioca
|
|
|
64
64
|
|
|
65
65
|
class << self
|
|
66
66
|
# @override
|
|
67
|
-
#: -> Enumerable[
|
|
67
|
+
#: -> Enumerable[Module[top]]
|
|
68
68
|
def gather_constants
|
|
69
69
|
descendants_of(::ActiveRecord::Base)
|
|
70
70
|
.reject(&:abstract_class?)
|
|
@@ -37,7 +37,7 @@ module Tapioca
|
|
|
37
37
|
# mixes_in_class_methods(::Foo::ClassMethods)
|
|
38
38
|
# end
|
|
39
39
|
# ~~~
|
|
40
|
-
#: [ConstantType =
|
|
40
|
+
#: [ConstantType = Module[top]]
|
|
41
41
|
class ActiveSupportConcern < Compiler
|
|
42
42
|
# @override
|
|
43
43
|
#: -> void
|
|
@@ -61,7 +61,7 @@ module Tapioca
|
|
|
61
61
|
|
|
62
62
|
class << self
|
|
63
63
|
# @override
|
|
64
|
-
#: -> Enumerable[
|
|
64
|
+
#: -> Enumerable[Module[top]]
|
|
65
65
|
def gather_constants
|
|
66
66
|
all_modules.select do |mod|
|
|
67
67
|
name_of(mod) && # i.e. not anonymous
|
|
@@ -72,10 +72,10 @@ module Tapioca
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
# Returns true when `mod` includes other concerns
|
|
75
|
-
#: (
|
|
75
|
+
#: (Module[top] mod) -> bool
|
|
76
76
|
def has_dependencies?(mod) = dependencies_of(mod).any?
|
|
77
77
|
|
|
78
|
-
#: (
|
|
78
|
+
#: (Module[top] concern) -> Array[Module[top]]
|
|
79
79
|
def dependencies_of(concern)
|
|
80
80
|
concern.instance_variable_get(:@_dependencies) || []
|
|
81
81
|
end
|
|
@@ -83,12 +83,12 @@ module Tapioca
|
|
|
83
83
|
|
|
84
84
|
private
|
|
85
85
|
|
|
86
|
-
#: (
|
|
86
|
+
#: (Module[top] concern) -> Array[Module[top]]
|
|
87
87
|
def dependencies_of(concern)
|
|
88
88
|
self.class.dependencies_of(concern)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
#: (?
|
|
91
|
+
#: (?Module[top] concern) -> Array[Module[top]]
|
|
92
92
|
def linearized_dependencies(concern = constant)
|
|
93
93
|
# Grab all the dependencies of the concern
|
|
94
94
|
dependencies = dependencies_of(concern)
|
|
@@ -40,7 +40,7 @@ module Tapioca
|
|
|
40
40
|
# def github=(value); end
|
|
41
41
|
# end
|
|
42
42
|
# ```
|
|
43
|
-
#: [ConstantType =
|
|
43
|
+
#: [ConstantType = Module[top]]
|
|
44
44
|
class Config < Compiler
|
|
45
45
|
CONFIG_OPTIONS_SUFFIX = "ConfigOptions"
|
|
46
46
|
|
|
@@ -92,7 +92,7 @@ module Tapioca
|
|
|
92
92
|
|
|
93
93
|
class << self
|
|
94
94
|
# @override
|
|
95
|
-
#: -> Enumerable[
|
|
95
|
+
#: -> Enumerable[Module[top]]
|
|
96
96
|
def gather_constants
|
|
97
97
|
name = ::Config.const_name
|
|
98
98
|
return [] unless Object.const_defined?(name)
|
|
@@ -57,7 +57,7 @@ module Tapioca
|
|
|
57
57
|
# ~~~
|
|
58
58
|
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
|
59
59
|
class IdentityCache < Compiler
|
|
60
|
-
COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((
|
|
60
|
+
COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((Module[top] | String) type) -> String
|
|
61
61
|
|
|
62
62
|
# @override
|
|
63
63
|
#: -> void
|
|
@@ -91,7 +91,7 @@ module Tapioca
|
|
|
91
91
|
|
|
92
92
|
class << self
|
|
93
93
|
# @override
|
|
94
|
-
#: -> Enumerable[
|
|
94
|
+
#: -> Enumerable[Module[top]]
|
|
95
95
|
def gather_constants
|
|
96
96
|
descendants_of(::ActiveRecord::Base).select do |klass|
|
|
97
97
|
::IdentityCache::WithoutPrimaryIndex > klass
|
|
@@ -44,7 +44,7 @@ module Tapioca
|
|
|
44
44
|
# end
|
|
45
45
|
# end
|
|
46
46
|
# ~~~
|
|
47
|
-
#: [ConstantType =
|
|
47
|
+
#: [ConstantType = Module[top]]
|
|
48
48
|
class MixedInClassAttributes < Compiler
|
|
49
49
|
# @override
|
|
50
50
|
#: -> void
|
|
@@ -59,7 +59,7 @@ module Tapioca
|
|
|
59
59
|
|
|
60
60
|
class << self
|
|
61
61
|
# @override
|
|
62
|
-
#: -> Enumerable[
|
|
62
|
+
#: -> Enumerable[Module[top]]
|
|
63
63
|
def gather_constants
|
|
64
64
|
# Select all non-anonymous modules that have overridden Module.included
|
|
65
65
|
all_modules.select do |mod|
|
|
@@ -109,7 +109,7 @@ module Tapioca
|
|
|
109
109
|
# end
|
|
110
110
|
# end
|
|
111
111
|
# ~~~
|
|
112
|
-
#: [ConstantType = (
|
|
112
|
+
#: [ConstantType = (Module[top] & ::StateMachines::ClassMethods)]
|
|
113
113
|
class StateMachines < Compiler
|
|
114
114
|
# @override
|
|
115
115
|
#: -> void
|
|
@@ -154,7 +154,7 @@ module Tapioca
|
|
|
154
154
|
|
|
155
155
|
class << self
|
|
156
156
|
# @override
|
|
157
|
-
#: -> Enumerable[
|
|
157
|
+
#: -> Enumerable[Module[top]]
|
|
158
158
|
def gather_constants
|
|
159
159
|
all_classes.select { |mod| ::StateMachines::InstanceMethods > mod }
|
|
160
160
|
end
|