sorbet-runtime 0.5.9771 → 0.5.9782
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/configuration.rb +13 -0
- data/lib/types/enum.rb +10 -6
- data/lib/types/private/abstract/data.rb +1 -1
- data/lib/types/private/sealed.rb +1 -1
- data/lib/types/props/constructor.rb +1 -1
- data/lib/types/props/decorator.rb +2 -2
- data/lib/types/props/has_lazily_specialized_methods.rb +2 -2
- data/lib/types/props/optional.rb +2 -2
- data/lib/types/props/serializable.rb +10 -5
- data/lib/types/props/weak_constructor.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb798bf398acaf5e2985a846a3597d6029504c6449b8c4496378c8127c2583e4
|
4
|
+
data.tar.gz: b935e9ccaf115fbe7980d02a6f07656441cef3e9913b88db7703df81ef65f316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef136790bd4bc97cfbc74fd6bfd9af5ccfe40fa4118ee3d0efbf6728b3d2d51bc4c835bd3657a82bdc1dfb6e2cbc9294d2eafc31d7617dbbd8d4d5046a00687
|
7
|
+
data.tar.gz: 01b03a74eec5d26a6fd9acfcdf8a3acc783af77b38f5a21e6b1228582b8fd53adeaa70a7a151416fc0fdde80f124b53bb155f6196551062b2604f5391054a379
|
data/lib/types/configuration.rb
CHANGED
@@ -80,6 +80,7 @@ module T::Configuration
|
|
80
80
|
T::Props::Private::DeserializerGenerator.respond_to?(:generate2)
|
81
81
|
end
|
82
82
|
|
83
|
+
@use_vm_prop_serde = false
|
83
84
|
# Whether to use VM-defined prop serialization/deserialization routines.
|
84
85
|
#
|
85
86
|
# The default is to use runtime codegen inside sorbet-runtime itself.
|
@@ -117,6 +118,7 @@ module T::Configuration
|
|
117
118
|
T::Private::RuntimeLevels.default_checked_level = default_checked_level
|
118
119
|
end
|
119
120
|
|
121
|
+
@inline_type_error_handler = nil
|
120
122
|
# Set a handler to handle `TypeError`s raised by any in-line type assertions,
|
121
123
|
# including `T.must`, `T.let`, `T.cast`, and `T.assert_type!`.
|
122
124
|
#
|
@@ -164,6 +166,7 @@ module T::Configuration
|
|
164
166
|
nil
|
165
167
|
end
|
166
168
|
|
169
|
+
@sig_builder_error_handler = nil
|
167
170
|
# Set a handler to handle errors that occur when the builder methods in the
|
168
171
|
# body of a sig are executed. The sig builder methods are inside a proc so
|
169
172
|
# that they can be lazily evaluated the first time the method being sig'd is
|
@@ -204,6 +207,7 @@ module T::Configuration
|
|
204
207
|
nil
|
205
208
|
end
|
206
209
|
|
210
|
+
@sig_validation_error_handler = nil
|
207
211
|
# Set a handler to handle sig validation errors.
|
208
212
|
#
|
209
213
|
# Sig validation errors include things like abstract checks, override checks,
|
@@ -254,6 +258,7 @@ module T::Configuration
|
|
254
258
|
nil
|
255
259
|
end
|
256
260
|
|
261
|
+
@call_validation_error_handler = nil
|
257
262
|
# Set a handler for type errors that result from calling a method.
|
258
263
|
#
|
259
264
|
# By default, errors from calling a method cause an exception to be raised.
|
@@ -300,6 +305,7 @@ module T::Configuration
|
|
300
305
|
nil
|
301
306
|
end
|
302
307
|
|
308
|
+
@log_info_handler = nil
|
303
309
|
# Set a handler for logging
|
304
310
|
#
|
305
311
|
# @param [Lambda, Proc, Object, nil] value Proc that handles the error
|
@@ -331,6 +337,7 @@ module T::Configuration
|
|
331
337
|
end
|
332
338
|
end
|
333
339
|
|
340
|
+
@soft_assert_handler = nil
|
334
341
|
# Set a handler for soft assertions
|
335
342
|
#
|
336
343
|
# These generally shouldn't stop execution of the program, but rather inform
|
@@ -365,6 +372,7 @@ module T::Configuration
|
|
365
372
|
end
|
366
373
|
end
|
367
374
|
|
375
|
+
@hard_assert_handler = nil
|
368
376
|
# Set a handler for hard assertions
|
369
377
|
#
|
370
378
|
# These generally should stop execution of the program, and optionally inform
|
@@ -399,6 +407,7 @@ module T::Configuration
|
|
399
407
|
end
|
400
408
|
end
|
401
409
|
|
410
|
+
@scalar_types = nil
|
402
411
|
# Set a list of class strings that are to be considered scalar.
|
403
412
|
# (pass nil to reset to default behavior)
|
404
413
|
#
|
@@ -461,6 +470,7 @@ module T::Configuration
|
|
461
470
|
@module_name_mangler = handler
|
462
471
|
end
|
463
472
|
|
473
|
+
@sensitivity_and_pii_handler = nil
|
464
474
|
# Set to a PII handler function. This will be called with the `sensitivity:`
|
465
475
|
# annotations on things that use `T::Props` and can modify them ahead-of-time.
|
466
476
|
#
|
@@ -490,6 +500,7 @@ module T::Configuration
|
|
490
500
|
@redaction_handler
|
491
501
|
end
|
492
502
|
|
503
|
+
@class_owner_finder = nil
|
493
504
|
# Set to a function which can get the 'owner' of a class. This is
|
494
505
|
# used in reporting deserialization errors
|
495
506
|
#
|
@@ -523,6 +534,7 @@ module T::Configuration
|
|
523
534
|
end
|
524
535
|
end
|
525
536
|
|
537
|
+
@legacy_t_enum_migration_mode = false
|
526
538
|
def self.enable_legacy_t_enum_migration_mode
|
527
539
|
@legacy_t_enum_migration_mode = true
|
528
540
|
end
|
@@ -543,6 +555,7 @@ module T::Configuration
|
|
543
555
|
@prop_freeze_handler
|
544
556
|
end
|
545
557
|
|
558
|
+
@sealed_violation_whitelist = nil
|
546
559
|
# @param [Array] sealed_violation_whitelist An array of Regexp to validate
|
547
560
|
# whether inheriting /including a sealed module outside the defining module
|
548
561
|
# should be allowed. Useful to whitelist benign violations, like shim files
|
data/lib/types/enum.rb
CHANGED
@@ -286,14 +286,18 @@ class T::Enum
|
|
286
286
|
|
287
287
|
sig {returns(T::Boolean)}
|
288
288
|
def self.started_initializing?
|
289
|
-
|
290
|
-
|
289
|
+
unless defined?(@started_initializing)
|
290
|
+
@started_initializing = T.let(false, T.nilable(T::Boolean))
|
291
|
+
end
|
292
|
+
T.must(@started_initializing)
|
291
293
|
end
|
292
294
|
|
293
295
|
sig {returns(T::Boolean)}
|
294
296
|
def self.fully_initialized?
|
295
|
-
|
296
|
-
|
297
|
+
unless defined?(@fully_initialized)
|
298
|
+
@fully_initialized = T.let(false, T.nilable(T::Boolean))
|
299
|
+
end
|
300
|
+
T.must(@fully_initialized)
|
297
301
|
end
|
298
302
|
|
299
303
|
# Maintains the order in which values are defined
|
@@ -308,8 +312,8 @@ class T::Enum
|
|
308
312
|
sig {params(blk: T.proc.void).void}
|
309
313
|
def self.enums(&blk)
|
310
314
|
raise "enums cannot be defined for T::Enum" if self == T::Enum
|
311
|
-
raise "Enum #{self} was already initialized" if
|
312
|
-
raise "Enum #{self} is still initializing" if
|
315
|
+
raise "Enum #{self} was already initialized" if fully_initialized?
|
316
|
+
raise "Enum #{self} is still initializing" if started_initializing?
|
313
317
|
|
314
318
|
@started_initializing = true
|
315
319
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# modules that override the `hash` method with something completely broken.
|
13
13
|
module T::Private::Abstract::Data
|
14
14
|
def self.get(mod, key)
|
15
|
-
mod.instance_variable_get("@opus_abstract__#{key}")
|
15
|
+
mod.instance_variable_get("@opus_abstract__#{key}") if key?(mod, key)
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.set(mod, key, value)
|
data/lib/types/private/sealed.rb
CHANGED
@@ -70,7 +70,7 @@ module T::Private::Sealed
|
|
70
70
|
|
71
71
|
def self.validate_inheritance(this_line, parent, child, verb)
|
72
72
|
this_file = this_line&.split(':')&.first
|
73
|
-
decl_file = parent.instance_variable_get(:@sorbet_sealed_module_decl_file)
|
73
|
+
decl_file = parent.instance_variable_get(:@sorbet_sealed_module_decl_file) if sealed_module?(parent)
|
74
74
|
|
75
75
|
if !this_file
|
76
76
|
raise "Could not use backtrace to determine file for #{verb} child #{child}"
|
@@ -20,7 +20,7 @@ module T::Props::Constructor::DecoratorMethods
|
|
20
20
|
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
21
21
|
# and therefore allocates for each entry.
|
22
22
|
result = 0
|
23
|
-
|
23
|
+
props_without_defaults&.each_pair do |p, setter_proc|
|
24
24
|
begin
|
25
25
|
val = hash[p]
|
26
26
|
instance.instance_exec(val, &setter_proc)
|
@@ -155,7 +155,7 @@ class T::Props::Decorator
|
|
155
155
|
.checked(:never)
|
156
156
|
end
|
157
157
|
def prop_get(instance, prop, rules=prop_rules(prop))
|
158
|
-
val = instance.instance_variable_get(rules[:accessor_key])
|
158
|
+
val = instance.instance_variable_get(rules[:accessor_key]) if instance.instance_variable_defined?(rules[:accessor_key])
|
159
159
|
if !val.nil?
|
160
160
|
val
|
161
161
|
elsif (d = rules[:ifunset])
|
@@ -175,7 +175,7 @@ class T::Props::Decorator
|
|
175
175
|
.checked(:never)
|
176
176
|
end
|
177
177
|
def prop_get_if_set(instance, prop, rules=prop_rules(prop))
|
178
|
-
instance.instance_variable_get(rules[:accessor_key])
|
178
|
+
instance.instance_variable_get(rules[:accessor_key]) if instance.instance_variable_defined?(rules[:accessor_key])
|
179
179
|
end
|
180
180
|
alias_method :get, :prop_get_if_set # Alias for backwards compatibility
|
181
181
|
|
@@ -37,7 +37,7 @@ module T::Props
|
|
37
37
|
|
38
38
|
sig {returns(T::Boolean)}
|
39
39
|
def self.lazy_evaluation_enabled?
|
40
|
-
!@lazy_evaluation_disabled
|
40
|
+
!defined?(@lazy_evaluation_disabled) || !@lazy_evaluation_disabled
|
41
41
|
end
|
42
42
|
|
43
43
|
module DecoratorMethods
|
@@ -84,7 +84,7 @@ module T::Props
|
|
84
84
|
|
85
85
|
cls = decorated_class
|
86
86
|
if cls.method_defined?(name)
|
87
|
-
# Ruby
|
87
|
+
# Ruby does not emit "method redefined" warnings for aliased methods
|
88
88
|
# (more robust than undef_method that would create a small window in which the method doesn't exist)
|
89
89
|
cls.send(:alias_method, name, name)
|
90
90
|
end
|
data/lib/types/props/optional.rb
CHANGED
@@ -49,13 +49,13 @@ module T::Props::Optional::DecoratorMethods
|
|
49
49
|
if default_setter
|
50
50
|
@props_with_defaults ||= {}
|
51
51
|
@props_with_defaults[prop] = default_setter
|
52
|
-
|
52
|
+
props_without_defaults&.delete(prop) # Handle potential override
|
53
53
|
|
54
54
|
rules[DEFAULT_SETTER_RULE_KEY] = default_setter
|
55
55
|
else
|
56
56
|
@props_without_defaults ||= {}
|
57
57
|
@props_without_defaults[prop] = rules.fetch(:setter_proc)
|
58
|
-
|
58
|
+
props_with_defaults&.delete(prop) # Handle potential override
|
59
59
|
end
|
60
60
|
|
61
61
|
super
|
@@ -35,7 +35,7 @@ module T::Props::Serializable
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
h.merge!(@_extra_props) if @_extra_props
|
38
|
+
h.merge!(@_extra_props) if defined?(@_extra_props)
|
39
39
|
h
|
40
40
|
end
|
41
41
|
|
@@ -121,8 +121,8 @@ module T::Props::Serializable
|
|
121
121
|
private def with_existing_hash(changed_props, existing_hash:)
|
122
122
|
serialized = existing_hash
|
123
123
|
new_val = self.class.from_hash(serialized.merge(recursive_stringify_keys(changed_props)))
|
124
|
-
old_extra = self.instance_variable_get(:@_extra_props)
|
125
|
-
new_extra = new_val.instance_variable_get(:@_extra_props)
|
124
|
+
old_extra = self.instance_variable_get(:@_extra_props) if self.instance_variable_defined?(:@_extra_props)
|
125
|
+
new_extra = new_val.instance_variable_get(:@_extra_props) if new_val.instance_variable_defined?(:@_extra_props)
|
126
126
|
if old_extra != new_extra
|
127
127
|
difference =
|
128
128
|
if old_extra
|
@@ -137,7 +137,8 @@ module T::Props::Serializable
|
|
137
137
|
|
138
138
|
# Asserts if this property is missing during strict serialize
|
139
139
|
private def required_prop_missing_from_serialize(prop)
|
140
|
-
if @_required_props_missing_from_deserialize
|
140
|
+
if defined?(@_required_props_missing_from_deserialize) &&
|
141
|
+
@_required_props_missing_from_deserialize&.include?(prop)
|
141
142
|
# If the prop was already missing during deserialization, that means the application
|
142
143
|
# code already had to deal with a nil value, which means we wouldn't be accomplishing
|
143
144
|
# much by raising here (other than causing an unnecessary breakage).
|
@@ -322,7 +323,11 @@ module T::Props::Serializable::DecoratorMethods
|
|
322
323
|
private_constant :EMPTY_EXTRA_PROPS
|
323
324
|
|
324
325
|
def extra_props(instance)
|
325
|
-
instance.
|
326
|
+
if instance.instance_variable_defined?(:@_extra_props)
|
327
|
+
instance.instance_variable_get(:@_extra_props)
|
328
|
+
else
|
329
|
+
instance.instance_variable_set(:@_extra_props, EMPTY_EXTRA_PROPS)
|
330
|
+
end
|
326
331
|
end
|
327
332
|
|
328
333
|
# overrides T::Props::PrettyPrintable
|
@@ -33,7 +33,7 @@ module T::Props::WeakConstructor::DecoratorMethods
|
|
33
33
|
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
34
34
|
# and therefore allocates for each entry.
|
35
35
|
result = 0
|
36
|
-
|
36
|
+
props_without_defaults&.each_pair do |p, setter_proc|
|
37
37
|
if hash.key?(p)
|
38
38
|
instance.instance_exec(hash[p], &setter_proc)
|
39
39
|
result += 1
|
@@ -54,7 +54,7 @@ module T::Props::WeakConstructor::DecoratorMethods
|
|
54
54
|
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
55
55
|
# and therefore allocates for each entry.
|
56
56
|
result = 0
|
57
|
-
|
57
|
+
props_with_defaults&.each_pair do |p, default_struct|
|
58
58
|
if hash.key?(p)
|
59
59
|
instance.instance_exec(hash[p], &default_struct.setter_proc)
|
60
60
|
result += 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sorbet-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9782
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|