sorbet-runtime 0.4.4323 → 0.4.4324
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/boolean.rb +1 -1
- data/lib/types/configuration.rb +12 -59
- data/lib/types/props/errors.rb +1 -1
- data/lib/types/runtime_profiled.rb +1 -1
- data/lib/types/sig.rb +2 -2
- data/lib/types/types/type_member.rb +1 -1
- data/lib/types/types/type_template.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a117936c3982c8ba0fa305ff6cdfc58c4570a63
|
4
|
+
data.tar.gz: 9871ba952fd1f97146f87f67784f6b01806beab0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30947911f3a2f17f1c15393e92b5312e4f160daea9aa9d036dd9ab9b3f0648f5824593b537be6520311b7a78fd64e41d969c0e5a0ec754bab18a1e9e24a903ee
|
7
|
+
data.tar.gz: 9bc0852dbd630a6ed3685c81d14ae77849afe4bb117a15b14d9b133dbd4085b2f3e6c9d43bcee6b636f9b68eb3b1da2bf93d1c9b0f5d750bc26c426b8835e607
|
data/lib/types/boolean.rb
CHANGED
data/lib/types/configuration.rb
CHANGED
@@ -99,11 +99,10 @@ module T::Configuration
|
|
99
99
|
# successfully built, but the built sig is incompatible with other sigs in
|
100
100
|
# some way.
|
101
101
|
#
|
102
|
-
# By default, sig validation errors cause an exception to be raised.
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
# behavior when a method signature's build fails.
|
102
|
+
# By default, sig validation errors cause an exception to be raised.
|
103
|
+
# Setting sig_validation_error_handler to an object that implements :call
|
104
|
+
# (e.g. proc or lambda) allows users to customize the behavior when a method
|
105
|
+
# signature's build fails.
|
107
106
|
#
|
108
107
|
# @param [Lambda, Proc, Object, nil] value Proc that handles the error (pass
|
109
108
|
# nil to reset to default behavior)
|
@@ -131,24 +130,7 @@ module T::Configuration
|
|
131
130
|
end
|
132
131
|
|
133
132
|
private_class_method def self.sig_validation_error_handler_default(error, opts)
|
134
|
-
|
135
|
-
bad_method = opts[:method]
|
136
|
-
if !opts[:declaration].generated
|
137
|
-
super_signature = opts[:super_signature]
|
138
|
-
raise error if !super_signature&.generated
|
139
|
-
bad_method = super_signature.method
|
140
|
-
end
|
141
|
-
|
142
|
-
method_file, method_line = bad_method.source_location
|
143
|
-
T::Configuration.log_info_handler(
|
144
|
-
"SIG-DECLARE-FAILED",
|
145
|
-
{
|
146
|
-
definition_file: method_file,
|
147
|
-
definition_line: method_line,
|
148
|
-
kind: "Delete",
|
149
|
-
message: error.message,
|
150
|
-
},
|
151
|
-
)
|
133
|
+
raise error
|
152
134
|
end
|
153
135
|
|
154
136
|
def self.sig_validation_error_handler(error, opts)
|
@@ -162,11 +144,9 @@ module T::Configuration
|
|
162
144
|
# Set a handler for type errors that result from calling a method.
|
163
145
|
#
|
164
146
|
# By default, errors from calling a method cause an exception to be raised.
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
# behavior when a method is called with invalid parameters, or returns an
|
169
|
-
# invalid value.
|
147
|
+
# Setting call_validation_error_handler to an object that implements :call
|
148
|
+
# (e.g. proc or lambda) allows users to customize the behavior when a method
|
149
|
+
# is called with invalid parameters, or returns an invalid value.
|
170
150
|
#
|
171
151
|
# @param [Lambda, Proc, Object, nil] value Proc that handles the error
|
172
152
|
# report (pass nil to reset to default behavior)
|
@@ -197,39 +177,12 @@ module T::Configuration
|
|
197
177
|
private_class_method def self.call_validation_error_handler_default(signature, opts)
|
198
178
|
method_file, method_line = signature.method.source_location
|
199
179
|
location = opts[:location]
|
200
|
-
suffix = "Caller: #{location.path}:#{location.lineno}\n" \
|
201
|
-
"Definition: #{method_file}:#{method_line}"
|
202
180
|
|
203
|
-
error_message = "#{opts[:kind]}#{opts[:name] ? " '#{opts[:name]}'" : ''}: #{opts[:message]}\n
|
181
|
+
error_message = "#{opts[:kind]}#{opts[:name] ? " '#{opts[:name]}'" : ''}: #{opts[:message]}\n" \
|
182
|
+
"Caller: #{location.path}:#{location.lineno}\n" \
|
183
|
+
"Definition: #{method_file}:#{method_line}"
|
204
184
|
|
205
|
-
|
206
|
-
got = opts[:value].class
|
207
|
-
got = T.unsafe(T::Enumerable[T.untyped]).describe_obj(opts[:value]) if got < Enumerable
|
208
|
-
T::Configuration.log_info_handler(
|
209
|
-
"SIG-CHECK-FAILED",
|
210
|
-
{
|
211
|
-
caller_file: location.path,
|
212
|
-
caller_line: location.lineno,
|
213
|
-
definition_file: method_file,
|
214
|
-
definition_line: method_line,
|
215
|
-
kind: opts[:kind],
|
216
|
-
name: opts[:name],
|
217
|
-
expected: opts[:type].name,
|
218
|
-
got: got,
|
219
|
-
},
|
220
|
-
)
|
221
|
-
elsif signature.soft_notify
|
222
|
-
T::Configuration.soft_assert_handler(
|
223
|
-
"TypeError: #{error_message}",
|
224
|
-
{notify: signature.soft_notify}
|
225
|
-
)
|
226
|
-
else
|
227
|
-
begin
|
228
|
-
raise TypeError.new(error_message)
|
229
|
-
rescue TypeError => e # raise into rescue to ensure e.backtrace is populated
|
230
|
-
T::Private::ErrorHandler.handle_inline_type_error(e)
|
231
|
-
end
|
232
|
-
end
|
185
|
+
raise TypeError.new(error_message)
|
233
186
|
end
|
234
187
|
|
235
188
|
def self.call_validation_error_handler(signature, opts)
|
data/lib/types/props/errors.rb
CHANGED
data/lib/types/sig.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# typed:
|
2
|
+
# typed: strict
|
3
3
|
|
4
4
|
# Used as a mixin to any class so that you can call `sig`.
|
5
5
|
# Docs at https://sorbet.org/docs/sigs
|
@@ -11,7 +11,7 @@ module T::Sig
|
|
11
11
|
|
12
12
|
# At runtime, does nothing, but statically it is treated exactly the same
|
13
13
|
# as T::Sig#sig. Only use it in cases where you can't use T::Sig#sig.
|
14
|
-
T::Sig::WithoutRuntime.sig {params(blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void}
|
14
|
+
T::Sig::WithoutRuntime.sig {params(blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void}
|
15
15
|
def self.sig(&blk); end # rubocop:disable PrisonGuard/BanBuiltinMethodOverride, Lint/DuplicateMethods
|
16
16
|
end
|
17
17
|
|