sorbet-runtime 0.5.10803 → 0.5.10804
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/props/decorator.rb +19 -19
- data/lib/types/props/type_validation.rb +2 -0
- 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: fa7a0490c3f7444ff040bb55e99d4fb52ee3943c97bd873427c52d58a67dee92
|
4
|
+
data.tar.gz: c2475595abbccc6900c35cb0747dc872ffc5fd0b8043d955a53bc8b5ecb6e13d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9367983c2a15754f5a2b39de9238d8d9ae387a6b1964edbd60e9d4f084877cd01a24a17095bc17dbb675b42f9b172f88f8a84560d585cc5af02f14e6bf83f9c
|
7
|
+
data.tar.gz: 65b7e38725846375455d4bef55314cc6e795a48c72761e9a24d2cd86764855e99351c93fa1beb59e62dc42f6f4c941853a8ddc15549532e7e2c78b065a7c706d
|
@@ -17,7 +17,7 @@ class T::Props::Decorator
|
|
17
17
|
|
18
18
|
class NoRulesError < StandardError; end
|
19
19
|
|
20
|
-
EMPTY_PROPS = T.let({}.freeze, T::Hash[Symbol, Rules])
|
20
|
+
EMPTY_PROPS = T.let({}.freeze, T::Hash[Symbol, Rules], checked: false)
|
21
21
|
private_constant :EMPTY_PROPS
|
22
22
|
|
23
23
|
sig {params(klass: T.untyped).void.checked(:never)}
|
@@ -26,7 +26,7 @@ class T::Props::Decorator
|
|
26
26
|
@class.plugins.each do |mod|
|
27
27
|
T::Props::Plugin::Private.apply_decorator_methods(mod, self)
|
28
28
|
end
|
29
|
-
@props = T.let(EMPTY_PROPS, T::Hash[Symbol, Rules])
|
29
|
+
@props = T.let(EMPTY_PROPS, T::Hash[Symbol, Rules], checked: false)
|
30
30
|
end
|
31
31
|
|
32
32
|
# checked(:never) - O(prop accesses)
|
@@ -79,7 +79,7 @@ class T::Props::Decorator
|
|
79
79
|
extra
|
80
80
|
setter_validate
|
81
81
|
_tnilable
|
82
|
-
].
|
82
|
+
].to_h {|k| [k, true]}.freeze, T::Hash[Symbol, T::Boolean], checked: false)
|
83
83
|
private_constant :VALID_RULE_KEYS
|
84
84
|
|
85
85
|
sig {params(key: Symbol).returns(T::Boolean).checked(:never)}
|
@@ -205,7 +205,7 @@ class T::Props::Decorator
|
|
205
205
|
end
|
206
206
|
|
207
207
|
# TODO: we should really be checking all the methods on `cls`, not just Object
|
208
|
-
BANNED_METHOD_NAMES = T.let(Object.instance_methods.each_with_object({}) {|x, acc| acc[x] = true}.freeze, T::Hash[Symbol, TrueClass])
|
208
|
+
BANNED_METHOD_NAMES = T.let(Object.instance_methods.each_with_object({}) {|x, acc| acc[x] = true}.freeze, T::Hash[Symbol, TrueClass], checked: false)
|
209
209
|
|
210
210
|
# checked(:never) - Rules hash is expensive to check
|
211
211
|
sig do
|
@@ -247,10 +247,10 @@ class T::Props::Decorator
|
|
247
247
|
nil
|
248
248
|
end
|
249
249
|
|
250
|
-
SAFE_NAME = T.let(/\A[A-Za-z_][A-Za-z0-9_-]*\z/.freeze, Regexp)
|
250
|
+
SAFE_NAME = T.let(/\A[A-Za-z_][A-Za-z0-9_-]*\z/.freeze, Regexp, checked: false)
|
251
251
|
|
252
252
|
# Used to validate both prop names and serialized forms
|
253
|
-
sig {params(name: T.any(Symbol, String)).void}
|
253
|
+
sig {params(name: T.any(Symbol, String)).void.checked(:never)}
|
254
254
|
private def validate_prop_name(name)
|
255
255
|
if !name.match?(SAFE_NAME)
|
256
256
|
raise ArgumentError.new("Invalid prop name in #{@class.name}: #{name}")
|
@@ -258,7 +258,7 @@ class T::Props::Decorator
|
|
258
258
|
end
|
259
259
|
|
260
260
|
# This converts the type from a T::Type to a regular old ruby class.
|
261
|
-
sig {params(type: T::Types::Base).returns(Module)}
|
261
|
+
sig {params(type: T::Types::Base).returns(Module).checked(:never)}
|
262
262
|
private def convert_type_to_class(type)
|
263
263
|
case type
|
264
264
|
when T::Types::TypedArray, T::Types::FixedArray
|
@@ -358,17 +358,14 @@ class T::Props::Decorator
|
|
358
358
|
end
|
359
359
|
end
|
360
360
|
|
361
|
-
rules =
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
# extra arbitrary metadata attached by the code defining this property
|
370
|
-
extra: rules[:extra]&.freeze,
|
371
|
-
)
|
361
|
+
rules[:type] = type
|
362
|
+
rules[:type_object] = type_object
|
363
|
+
rules[:accessor_key] = "@#{name}".to_sym
|
364
|
+
rules[:sensitivity] = sensitivity_and_pii[:sensitivity]
|
365
|
+
rules[:pii] = sensitivity_and_pii[:pii]
|
366
|
+
rules[:extra] = rules[:extra]&.freeze
|
367
|
+
|
368
|
+
# extra arbitrary metadata attached by the code defining this property
|
372
369
|
|
373
370
|
validate_not_missing_sensitivity(name, rules)
|
374
371
|
|
@@ -422,6 +419,7 @@ class T::Props::Decorator
|
|
422
419
|
sig do
|
423
420
|
params(type: PropTypeOrClass, enum: T.untyped)
|
424
421
|
.returns(T::Types::Base)
|
422
|
+
.checked(:never)
|
425
423
|
end
|
426
424
|
private def smart_coerce(type, enum:)
|
427
425
|
# Backwards compatibility for pre-T::Types style
|
@@ -474,6 +472,7 @@ class T::Props::Decorator
|
|
474
472
|
redaction: T.untyped,
|
475
473
|
)
|
476
474
|
.void
|
475
|
+
.checked(:never)
|
477
476
|
end
|
478
477
|
private def handle_redaction_option(prop_name, redaction)
|
479
478
|
redacted_method = "#{prop_name}_redacted"
|
@@ -495,6 +494,7 @@ class T::Props::Decorator
|
|
495
494
|
valid_type_msg: String,
|
496
495
|
)
|
497
496
|
.void
|
497
|
+
.checked(:never)
|
498
498
|
end
|
499
499
|
private def validate_foreign_option(option_sym, foreign, valid_type_msg:)
|
500
500
|
if foreign.is_a?(Symbol) || foreign.is_a?(String)
|
@@ -526,8 +526,8 @@ class T::Props::Decorator
|
|
526
526
|
# here, but we're baking in `allow_direct_mutation` since we
|
527
527
|
# *haven't* allowed additional options in the past and want to
|
528
528
|
# default to keeping this interface narrow.
|
529
|
+
foreign = T.let(foreign, T.untyped, checked: false)
|
529
530
|
@class.send(:define_method, fk_method) do |allow_direct_mutation: nil|
|
530
|
-
foreign = T.let(foreign, T.untyped)
|
531
531
|
if foreign.is_a?(Proc)
|
532
532
|
resolved_foreign = foreign.call
|
533
533
|
if !resolved_foreign.respond_to?(:load)
|
@@ -16,6 +16,7 @@ module T::Props::TypeValidation
|
|
16
16
|
super || key == :DEPRECATED_underspecified_type
|
17
17
|
end
|
18
18
|
|
19
|
+
# checked(:never) - Rules hash is expensive to check
|
19
20
|
sig do
|
20
21
|
params(
|
21
22
|
name: T.any(Symbol, String),
|
@@ -24,6 +25,7 @@ module T::Props::TypeValidation
|
|
24
25
|
type: T.any(T::Types::Base, Module)
|
25
26
|
)
|
26
27
|
.void
|
28
|
+
.checked(:never)
|
27
29
|
end
|
28
30
|
def prop_validate_definition!(name, _cls, rules, type)
|
29
31
|
super
|
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.10804
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|