tapioca 0.4.22 → 0.4.23
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/exe/tapioca +2 -0
- data/lib/tapioca/compilers/dsl/active_job.rb +19 -11
- data/lib/tapioca/compilers/symbol_table/symbol_generator.rb +22 -3
- data/lib/tapioca/gemfile.rb +23 -3
- data/lib/tapioca/internal.rb +1 -0
- data/lib/tapioca/sorbet_ext/fixed_hash_patch.rb +20 -0
- data/lib/tapioca/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fe702a52ed1226bf7c94e4288d722665e8444e89066a7cb9fda8066a2bebc3a
|
4
|
+
data.tar.gz: 1bb7b3bd18bf1b136b6c01afe6f27a82a49c31558a5298ebe2fb045476f7ec0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75ba6fe1ba52763c5c31f6f792f2bc766d8874fbd4814bd16137e3238926c1efb35bb4663bdc8ae423bed1d489425b5f3a569e41b2e75d8318ab7cad800f597c
|
7
|
+
data.tar.gz: e15284dee1f66fca6a032194b359f54523bbc2c3981423268ffd3402e74bdd66403a08239c712145b0455fa7b0c4d7c5600d9d5ae398d9dd2b88cf4ddc3376c7
|
data/exe/tapioca
CHANGED
@@ -5,6 +5,8 @@ require 'sorbet-runtime'
|
|
5
5
|
|
6
6
|
begin
|
7
7
|
T::Configuration.default_checked_level = :never
|
8
|
+
# Suppresses call validation errors
|
9
|
+
T::Configuration.call_validation_error_handler = ->(*) {}
|
8
10
|
# Suppresses errors caused by T.cast, T.let, T.must, etc.
|
9
11
|
T::Configuration.inline_type_error_handler = ->(*) {}
|
10
12
|
# Suppresses errors caused by incorrect parameter ordering
|
@@ -19,6 +19,7 @@ module Tapioca
|
|
19
19
|
#
|
20
20
|
# ~~~rb
|
21
21
|
# class NotifyUserJob < ActiveJob::Base
|
22
|
+
# sig { params(user: User).returns(Mail) }
|
22
23
|
# def perform(user)
|
23
24
|
# # ...
|
24
25
|
# end
|
@@ -31,10 +32,10 @@ module Tapioca
|
|
31
32
|
# # notify_user_job.rbi
|
32
33
|
# # typed: true
|
33
34
|
# class NotifyUserJob
|
34
|
-
# sig { params(user:
|
35
|
+
# sig { params(user: User).returns(T.any(NotifyUserJob, FalseClass)) }
|
35
36
|
# def self.perform_later(user); end
|
36
37
|
#
|
37
|
-
# sig { params(user:
|
38
|
+
# sig { params(user: User).returns(Mail) }
|
38
39
|
# def self.perform_now(user); end
|
39
40
|
# end
|
40
41
|
# ~~~
|
@@ -48,16 +49,23 @@ module Tapioca
|
|
48
49
|
|
49
50
|
method = constant.instance_method(:perform)
|
50
51
|
parameters = compile_method_parameters_to_parlour(method)
|
52
|
+
return_type = compile_method_return_type_to_parlour(method)
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
create_method(
|
55
|
+
job,
|
56
|
+
"perform_later",
|
57
|
+
parameters: parameters,
|
58
|
+
return_type: "T.any(#{constant.name}, FalseClass)",
|
59
|
+
class_method: true
|
60
|
+
)
|
61
|
+
|
62
|
+
create_method(
|
63
|
+
job,
|
64
|
+
"perform_now",
|
65
|
+
parameters: parameters,
|
66
|
+
return_type: return_type,
|
67
|
+
class_method: true
|
68
|
+
)
|
61
69
|
end
|
62
70
|
end
|
63
71
|
|
@@ -145,7 +145,15 @@ module Tapioca
|
|
145
145
|
def compile_object(tree, name, value)
|
146
146
|
return if symbol_ignored?(name)
|
147
147
|
klass = class_of(value)
|
148
|
-
|
148
|
+
|
149
|
+
klass_name = if klass == ObjectSpace::WeakMap
|
150
|
+
# WeakMap is an implicit generic with one type variable
|
151
|
+
"ObjectSpace::WeakMap[T.untyped]"
|
152
|
+
elsif T::Generic === klass
|
153
|
+
generic_name_of(klass)
|
154
|
+
else
|
155
|
+
name_of(klass)
|
156
|
+
end
|
149
157
|
|
150
158
|
if klass_name == "T::Private::Types::TypeAlias"
|
151
159
|
tree << RBI::Const.new(name, "T.type_alias { #{T.unsafe(value).aliased_type} }")
|
@@ -155,8 +163,6 @@ module Tapioca
|
|
155
163
|
return if klass_name&.start_with?("T::Types::", "T::Private::")
|
156
164
|
|
157
165
|
type_name = klass_name || "T.untyped"
|
158
|
-
# TODO: Do this in a more generic and clean way.
|
159
|
-
type_name = "#{type_name}[T.untyped]" if type_name == "ObjectSpace::WeakMap"
|
160
166
|
|
161
167
|
tree << RBI::Const.new(name, "T.let(T.unsafe(nil), #{type_name})")
|
162
168
|
end
|
@@ -774,6 +780,19 @@ module Tapioca
|
|
774
780
|
name
|
775
781
|
end
|
776
782
|
|
783
|
+
sig { params(constant: T.all(Module, T::Generic)).returns(String) }
|
784
|
+
def generic_name_of(constant)
|
785
|
+
type_name = T.must(constant.name)
|
786
|
+
return type_name if type_name =~ /\[.*\]$/
|
787
|
+
|
788
|
+
type_variables = Tapioca::GenericTypeRegistry.lookup_type_variables(constant)
|
789
|
+
return type_name unless type_variables
|
790
|
+
|
791
|
+
type_variable_names = type_variables.map { "T.untyped" }.join(", ")
|
792
|
+
|
793
|
+
"#{type_name}[#{type_variable_names}]"
|
794
|
+
end
|
795
|
+
|
777
796
|
sig { params(constant: Module).returns(T.nilable(String)) }
|
778
797
|
def name_of_proxy_target(constant)
|
779
798
|
klass = class_of(constant)
|
data/lib/tapioca/gemfile.rb
CHANGED
@@ -108,8 +108,14 @@ module Tapioca
|
|
108
108
|
|
109
109
|
sig { returns(T::Array[Pathname]) }
|
110
110
|
def files
|
111
|
-
|
112
|
-
|
111
|
+
if default_gem?
|
112
|
+
@spec.files.map do |file|
|
113
|
+
ruby_lib_dir.join(file)
|
114
|
+
end
|
115
|
+
else
|
116
|
+
@spec.full_require_paths.flat_map do |path|
|
117
|
+
Pathname.glob((Pathname.new(path) / "**/*.rb").to_s)
|
118
|
+
end
|
113
119
|
end
|
114
120
|
end
|
115
121
|
|
@@ -125,11 +131,25 @@ module Tapioca
|
|
125
131
|
|
126
132
|
sig { params(path: String).returns(T::Boolean) }
|
127
133
|
def contains_path?(path)
|
128
|
-
|
134
|
+
if default_gem?
|
135
|
+
files.any? { |file| file.to_s == to_realpath(path) }
|
136
|
+
else
|
137
|
+
to_realpath(path).start_with?(full_gem_path) || has_parent_gemspec?(path)
|
138
|
+
end
|
129
139
|
end
|
130
140
|
|
131
141
|
private
|
132
142
|
|
143
|
+
sig { returns(T::Boolean) }
|
144
|
+
def default_gem?
|
145
|
+
@spec.respond_to?(:default_gem?) && @spec.default_gem?
|
146
|
+
end
|
147
|
+
|
148
|
+
sig { returns(Pathname) }
|
149
|
+
def ruby_lib_dir
|
150
|
+
Pathname.new(RbConfig::CONFIG["rubylibdir"])
|
151
|
+
end
|
152
|
+
|
133
153
|
sig { returns(String) }
|
134
154
|
def version_string
|
135
155
|
version = @spec.version.to_s
|
data/lib/tapioca/internal.rb
CHANGED
@@ -6,6 +6,7 @@ require "tapioca/loader"
|
|
6
6
|
require "tapioca/constant_locator"
|
7
7
|
require "tapioca/generic_type_registry"
|
8
8
|
require "tapioca/sorbet_ext/generic_name_patch"
|
9
|
+
require "tapioca/sorbet_ext/fixed_hash_patch"
|
9
10
|
require "tapioca/config"
|
10
11
|
require "tapioca/config_builder"
|
11
12
|
require "tapioca/generator"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module T
|
5
|
+
module Types
|
6
|
+
class FixedHash
|
7
|
+
def name
|
8
|
+
entries = @types.map do |(k, v)|
|
9
|
+
if Symbol === k && ":#{k}" == k.inspect
|
10
|
+
"#{k}: #{v}"
|
11
|
+
else
|
12
|
+
"#{k.inspect} => #{v}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
"{#{entries.join(', ')}}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/tapioca/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-05-
|
14
|
+
date: 2021-05-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- lib/tapioca/rbi/rewriters/nest_singleton_methods.rb
|
169
169
|
- lib/tapioca/rbi/rewriters/sort_nodes.rb
|
170
170
|
- lib/tapioca/rbi/visitor.rb
|
171
|
+
- lib/tapioca/sorbet_ext/fixed_hash_patch.rb
|
171
172
|
- lib/tapioca/sorbet_ext/generic_name_patch.rb
|
172
173
|
- lib/tapioca/sorbet_ext/name_patch.rb
|
173
174
|
- lib/tapioca/version.rb
|