tapioca 0.19.2 → 0.20.0
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/README.md +87 -45
- data/lib/ruby_lsp/tapioca/run_gem_rbi_check.rb +1 -1
- data/lib/tapioca/cli.rb +10 -11
- data/lib/tapioca/commands/abstract_dsl.rb +71 -20
- data/lib/tapioca/commands/abstract_gem.rb +1 -0
- data/lib/tapioca/commands/annotations.rb +1 -1
- data/lib/tapioca/commands/dsl_generate.rb +0 -15
- data/lib/tapioca/commands/gem_generate.rb +20 -4
- data/lib/tapioca/dsl/compiler.rb +24 -10
- data/lib/tapioca/dsl/compilers/aasm.rb +24 -17
- 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_record_fixtures.rb +17 -11
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +2 -2
- data/lib/tapioca/dsl/compilers/config.rb +1 -1
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
- data/lib/tapioca/dsl/compilers/url_helpers.rb +312 -8
- data/lib/tapioca/dsl/compilers.rb +1 -1
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +7 -2
- data/lib/tapioca/dsl/pipeline.rb +3 -0
- data/lib/tapioca/gem/events.rb +1 -1
- data/lib/tapioca/gem/listeners/documentation.rb +13 -8
- data/lib/tapioca/gem/listeners/methods.rb +79 -13
- data/lib/tapioca/gem/listeners/sorbet_enums.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +3 -3
- data/lib/tapioca/gemfile.rb +13 -0
- data/lib/tapioca/helpers/env_helper.rb +1 -1
- data/lib/tapioca/helpers/file_helper.rb +42 -0
- data/lib/tapioca/helpers/rbi_files_helper.rb +96 -5
- data/lib/tapioca/helpers/rbi_helper.rb +17 -3
- data/lib/tapioca/helpers/sorbet_helper.rb +1 -1
- data/lib/tapioca/internal.rb +1 -0
- data/lib/tapioca/loaders/gem.rb +33 -0
- data/lib/tapioca/loaders/loader.rb +0 -13
- data/lib/tapioca/rbi_ext/model.rb +16 -2
- data/lib/tapioca/rbs/bootsnap_cache.rb +52 -0
- data/lib/tapioca/rbs/rewriter.rb +32 -21
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +1 -2
- data/lib/tapioca/runtime/generic_type_registry.rb +27 -2
- data/lib/tapioca/runtime/reflection.rb +18 -1
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +11 -10
- metadata +6 -4
|
@@ -25,11 +25,18 @@ module Tapioca
|
|
|
25
25
|
|
|
26
26
|
@type_variables = {}.compare_by_identity #: Hash[Module[top], Array[TypeVariableModule]]
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
# Subclasses `T::Types::Base` rather than `T::Types::Simple` so that all
|
|
29
|
+
# validation goes through the `valid?` override below. `Simple` fast paths
|
|
30
|
+
# check `raw_type` directly, which for us is the clone, not the underlying type.
|
|
31
|
+
class GenericType < T::Types::Base
|
|
32
|
+
#: Module[top]
|
|
33
|
+
attr_reader :raw_type
|
|
34
|
+
|
|
29
35
|
#: (Module[top] raw_type, Module[top] underlying_type) -> void
|
|
30
36
|
def initialize(raw_type, underlying_type)
|
|
31
|
-
super(
|
|
37
|
+
super()
|
|
32
38
|
|
|
39
|
+
@raw_type = raw_type
|
|
33
40
|
@underlying_type = underlying_type #: Module[top]
|
|
34
41
|
end
|
|
35
42
|
|
|
@@ -38,6 +45,24 @@ module Tapioca
|
|
|
38
45
|
def valid?(obj)
|
|
39
46
|
obj.is_a?(@underlying_type)
|
|
40
47
|
end
|
|
48
|
+
|
|
49
|
+
# @override
|
|
50
|
+
#: -> String
|
|
51
|
+
def name
|
|
52
|
+
T.must(@raw_type.name)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# @override
|
|
56
|
+
#: -> nil
|
|
57
|
+
def build_type
|
|
58
|
+
nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Matches the always-true `<=` we define on the clone in `create_generic_type`.
|
|
62
|
+
#: (T::Types::Base type) -> bool
|
|
63
|
+
private def subtype_of_single?(type)
|
|
64
|
+
true
|
|
65
|
+
end
|
|
41
66
|
end
|
|
42
67
|
|
|
43
68
|
class << self
|
|
@@ -125,7 +125,24 @@ module Tapioca
|
|
|
125
125
|
|
|
126
126
|
#: ((UnboundMethod | Method) method) -> untyped
|
|
127
127
|
def signature_of!(method)
|
|
128
|
-
T::Utils.signature_for_method(method)
|
|
128
|
+
signature = T::Utils.signature_for_method(method)
|
|
129
|
+
return signature if signature
|
|
130
|
+
|
|
131
|
+
# Walk the super method chain to evaluate pending signatures that may have been hidden by `prepend`.
|
|
132
|
+
# During that walk, Sorbet may register a signature on the requested wrapper, so check it again.
|
|
133
|
+
# See https://github.com/Shopify/tapioca/issues/2710 for details.
|
|
134
|
+
current_method = method.super_method #: (UnboundMethod | Method)?
|
|
135
|
+
while current_method
|
|
136
|
+
# force evaluation of the signature
|
|
137
|
+
_ = T::Utils.signature_for_method(current_method)
|
|
138
|
+
|
|
139
|
+
evaluated_signature = T::Utils.signature_for_method(method)
|
|
140
|
+
return evaluated_signature if evaluated_signature
|
|
141
|
+
|
|
142
|
+
current_method = current_method.super_method
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
nil
|
|
129
146
|
rescue LoadError, StandardError
|
|
130
147
|
Kernel.raise SignatureBlockError
|
|
131
148
|
end
|
data/lib/tapioca/version.rb
CHANGED
data/lib/tapioca.rb
CHANGED
|
@@ -11,18 +11,18 @@ module Tapioca
|
|
|
11
11
|
|
|
12
12
|
LIB_ROOT_DIR = T.must(__dir__) #: String
|
|
13
13
|
SORBET_DIR = "sorbet" #: String
|
|
14
|
-
SORBET_CONFIG_FILE = "#{SORBET_DIR}/config" #: String
|
|
15
|
-
TAPIOCA_DIR = "#{SORBET_DIR}/tapioca" #: String
|
|
16
|
-
TAPIOCA_CONFIG_FILE = "#{TAPIOCA_DIR}/config.yml" #: String
|
|
14
|
+
SORBET_CONFIG_FILE = "#{SORBET_DIR}/config".freeze #: String
|
|
15
|
+
TAPIOCA_DIR = "#{SORBET_DIR}/tapioca".freeze #: String
|
|
16
|
+
TAPIOCA_CONFIG_FILE = "#{TAPIOCA_DIR}/config.yml".freeze #: String
|
|
17
17
|
|
|
18
18
|
BINARY_FILE = "bin/tapioca" #: String
|
|
19
|
-
DEFAULT_POSTREQUIRE_FILE = "#{TAPIOCA_DIR}/require.rb" #: String
|
|
20
|
-
DEFAULT_RBI_DIR = "#{SORBET_DIR}/rbi" #: String
|
|
21
|
-
DEFAULT_DSL_DIR = "#{DEFAULT_RBI_DIR}/dsl" #: String
|
|
22
|
-
DEFAULT_GEM_DIR = "#{DEFAULT_RBI_DIR}/gems" #: String
|
|
23
|
-
DEFAULT_SHIM_DIR = "#{DEFAULT_RBI_DIR}/shims" #: String
|
|
24
|
-
DEFAULT_TODO_FILE = "#{DEFAULT_RBI_DIR}/todo.rbi" #: String
|
|
25
|
-
DEFAULT_ANNOTATIONS_DIR = "#{DEFAULT_RBI_DIR}/annotations" #: String
|
|
19
|
+
DEFAULT_POSTREQUIRE_FILE = "#{TAPIOCA_DIR}/require.rb".freeze #: String
|
|
20
|
+
DEFAULT_RBI_DIR = "#{SORBET_DIR}/rbi".freeze #: String
|
|
21
|
+
DEFAULT_DSL_DIR = "#{DEFAULT_RBI_DIR}/dsl".freeze #: String
|
|
22
|
+
DEFAULT_GEM_DIR = "#{DEFAULT_RBI_DIR}/gems".freeze #: String
|
|
23
|
+
DEFAULT_SHIM_DIR = "#{DEFAULT_RBI_DIR}/shims".freeze #: String
|
|
24
|
+
DEFAULT_TODO_FILE = "#{DEFAULT_RBI_DIR}/todo.rbi".freeze #: String
|
|
25
|
+
DEFAULT_ANNOTATIONS_DIR = "#{DEFAULT_RBI_DIR}/annotations".freeze #: String
|
|
26
26
|
|
|
27
27
|
DEFAULT_OVERRIDES = {
|
|
28
28
|
# ActiveSupport overrides some core methods with different signatures
|
|
@@ -32,6 +32,7 @@ module Tapioca
|
|
|
32
32
|
|
|
33
33
|
DEFAULT_RBI_MAX_LINE_LENGTH = 120
|
|
34
34
|
DEFAULT_ENVIRONMENT = "development"
|
|
35
|
+
DEFAULT_MAX_DIFF_LINES = 250
|
|
35
36
|
|
|
36
37
|
CENTRAL_REPO_ROOT_URI = "https://raw.githubusercontent.com/Shopify/rbi-central/main"
|
|
37
38
|
CENTRAL_REPO_INDEX_PATH = "index.json"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tapioca
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ufuk Kayserilioglu
|
|
@@ -130,14 +130,14 @@ dependencies:
|
|
|
130
130
|
requirements:
|
|
131
131
|
- - ">="
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
|
-
version: 0.
|
|
133
|
+
version: 0.4.1
|
|
134
134
|
type: :runtime
|
|
135
135
|
prerelease: false
|
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
|
137
137
|
requirements:
|
|
138
138
|
- - ">="
|
|
139
139
|
- !ruby/object:Gem::Version
|
|
140
|
-
version: 0.
|
|
140
|
+
version: 0.4.1
|
|
141
141
|
- !ruby/object:Gem::Dependency
|
|
142
142
|
name: spoom
|
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -273,6 +273,7 @@ files:
|
|
|
273
273
|
- lib/tapioca/helpers/cli_helper.rb
|
|
274
274
|
- lib/tapioca/helpers/config_helper.rb
|
|
275
275
|
- lib/tapioca/helpers/env_helper.rb
|
|
276
|
+
- lib/tapioca/helpers/file_helper.rb
|
|
276
277
|
- lib/tapioca/helpers/gem_helper.rb
|
|
277
278
|
- lib/tapioca/helpers/git_attributes.rb
|
|
278
279
|
- lib/tapioca/helpers/package_url.rb
|
|
@@ -289,6 +290,7 @@ files:
|
|
|
289
290
|
- lib/tapioca/loaders/loader.rb
|
|
290
291
|
- lib/tapioca/rbi_ext/model.rb
|
|
291
292
|
- lib/tapioca/rbi_formatter.rb
|
|
293
|
+
- lib/tapioca/rbs/bootsnap_cache.rb
|
|
292
294
|
- lib/tapioca/rbs/rewriter.rb
|
|
293
295
|
- lib/tapioca/repo_index.rb
|
|
294
296
|
- lib/tapioca/runtime/dynamic_mixin_compiler.rb
|
|
@@ -325,7 +327,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
325
327
|
requirements:
|
|
326
328
|
- - ">="
|
|
327
329
|
- !ruby/object:Gem::Version
|
|
328
|
-
version: '3.
|
|
330
|
+
version: '3.3'
|
|
329
331
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
332
|
requirements:
|
|
331
333
|
- - ">="
|