sorbet-runtime 0.5.10803 → 0.5.10805
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 +21 -21
- 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: 8aaf11e42b38458ad4f9df3fcccea9d2e9c3abcb16cfc6b68e63464537ecf9eb
|
4
|
+
data.tar.gz: c5736c17b5d9152b421062d3fd5db31b7ce6d64a512e23ed11d417cb46fb3c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7184b5d378814c673d1f65ca83c0c4c206892775fbbe543bcefbd0aa873df3abd0564a27a6cb32410b1e5a13c77de82d4729eecb82132cf5f0404905272cebb9
|
7
|
+
data.tar.gz: e3caf0d197620e66f66b1ae81d381755aa9a06055829e6a8c7ad46bf4e0a3b4a289ebb8ed477237cffd5eaa7ffd29699e6c544f0f524ff92de37a3501315576a
|
@@ -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)
|
@@ -50,9 +50,9 @@ class T::Props::Decorator
|
|
50
50
|
override = rules.delete(:override)
|
51
51
|
|
52
52
|
if props.include?(prop) && !override
|
53
|
-
raise ArgumentError.new("Attempted to redefine prop #{prop.inspect} that's already defined without specifying :override => true: #{prop_rules(prop)}")
|
53
|
+
raise ArgumentError.new("Attempted to redefine prop #{prop.inspect} on class #{@class} that's already defined without specifying :override => true: #{prop_rules(prop)}")
|
54
54
|
elsif !props.include?(prop) && override
|
55
|
-
raise ArgumentError.new("Attempted to override a prop #{prop.inspect} that doesn't already exist")
|
55
|
+
raise ArgumentError.new("Attempted to override a prop #{prop.inspect} on class #{@class} that doesn't already exist")
|
56
56
|
end
|
57
57
|
|
58
58
|
@props = @props.merge(prop => rules.freeze).freeze
|
@@ -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.10805
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|