sorbet-runtime 0.5.5284 → 0.5.5316
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/lib/types/private/sealed.rb +1 -1
- data/lib/types/props/decorator.rb +21 -37
- data/lib/types/props/optional.rb +0 -7
- data/lib/types/props/serializable.rb +1 -1
- 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: 96ac3f40e289c8880e546f48cc793e4e12461e713ac5a6d5daf9777d91af2774
|
|
4
|
+
data.tar.gz: 425ccca3f410868f357385eba3bbf0e8cc9cdd4b2cdc252137b0da96b36d5002
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28df096a88491a837b89157f6b3fb2a779d0e61729e0c9363740a9fa8ddef7d23156f0c910fcc0b9569daba0826dfef9e22441bb82718872923a444c09b9536c
|
|
7
|
+
data.tar.gz: cae44a94689f106188a491200eccf8b0da90e61ce2b089f79dbf8bcbb0ac4c486c9a10934f3647762aa3c179df677bfeee571665e1154b5929ebb8275ed3d7cf
|
data/lib/types/private/sealed.rb
CHANGED
|
@@ -55,7 +55,7 @@ module T::Private::Sealed
|
|
|
55
55
|
|
|
56
56
|
if !this_file.start_with?(decl_file)
|
|
57
57
|
whitelist = T::Configuration.sealed_violation_whitelist
|
|
58
|
-
if whitelist != nil && whitelist.any? {|pattern|
|
|
58
|
+
if whitelist != nil && whitelist.any? {|pattern| this_file =~ pattern}
|
|
59
59
|
return
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -33,15 +33,6 @@ class T::Props::Decorator
|
|
|
33
33
|
sig {returns(T::Hash[Symbol, Rules]).checked(:never)}
|
|
34
34
|
attr_reader :props
|
|
35
35
|
|
|
36
|
-
# Try to avoid using this; post-definition mutation of prop rules is
|
|
37
|
-
# surprising and hard to reason about.
|
|
38
|
-
sig {params(prop: Symbol, key: Symbol, value: T.untyped).void}
|
|
39
|
-
def mutate_prop_backdoor!(prop, key, value)
|
|
40
|
-
@props = props.merge(
|
|
41
|
-
prop => props.fetch(prop).merge(key => value).freeze
|
|
42
|
-
).freeze
|
|
43
|
-
end
|
|
44
|
-
|
|
45
36
|
sig {returns(T::Array[Symbol])}
|
|
46
37
|
def all_props; props.keys; end
|
|
47
38
|
|
|
@@ -91,25 +82,6 @@ class T::Props::Decorator
|
|
|
91
82
|
|
|
92
83
|
# Accessors
|
|
93
84
|
|
|
94
|
-
# For performance, don't use named params here.
|
|
95
|
-
# Passing in rules here is purely a performance optimization.
|
|
96
|
-
#
|
|
97
|
-
# checked(:never) - O(prop accesses)
|
|
98
|
-
sig do
|
|
99
|
-
params(
|
|
100
|
-
instance: DecoratedInstance,
|
|
101
|
-
prop: T.any(String, Symbol),
|
|
102
|
-
rules: T.nilable(Rules)
|
|
103
|
-
)
|
|
104
|
-
.returns(T.untyped)
|
|
105
|
-
.checked(:never)
|
|
106
|
-
end
|
|
107
|
-
def get(instance, prop, rules=props[prop.to_sym])
|
|
108
|
-
# For backwards compatibility, fall back to reconstructing the accessor key
|
|
109
|
-
# (though it would probably make more sense to raise in that case).
|
|
110
|
-
instance.instance_variable_get(rules ? rules[:accessor_key] : '@' + prop.to_s) # rubocop:disable PrisonGuard/NoLurkyInstanceVariableAccess
|
|
111
|
-
end
|
|
112
|
-
|
|
113
85
|
# Use this to validate that a value will validate for a given prop. Useful for knowing whether a value can be set on a model without setting it.
|
|
114
86
|
#
|
|
115
87
|
# checked(:never) - potentially O(prop accesses) depending on usage pattern
|
|
@@ -157,20 +129,17 @@ class T::Props::Decorator
|
|
|
157
129
|
params(
|
|
158
130
|
instance: DecoratedInstance,
|
|
159
131
|
prop: T.any(String, Symbol),
|
|
160
|
-
rules:
|
|
132
|
+
rules: Rules
|
|
161
133
|
)
|
|
162
134
|
.returns(T.untyped)
|
|
163
135
|
.checked(:never)
|
|
164
136
|
end
|
|
165
|
-
def prop_get(instance, prop, rules=
|
|
166
|
-
val =
|
|
167
|
-
|
|
137
|
+
def prop_get(instance, prop, rules=prop_rules(prop))
|
|
138
|
+
val = instance.instance_variable_get(rules[:accessor_key])
|
|
168
139
|
if !val.nil?
|
|
169
140
|
val
|
|
170
141
|
else
|
|
171
|
-
|
|
172
|
-
d = rules[:ifunset]
|
|
173
|
-
if d
|
|
142
|
+
if (d = rules[:ifunset])
|
|
174
143
|
T::Props::Utils.deep_clone_object(d)
|
|
175
144
|
else
|
|
176
145
|
nil
|
|
@@ -178,6 +147,20 @@ class T::Props::Decorator
|
|
|
178
147
|
end
|
|
179
148
|
end
|
|
180
149
|
|
|
150
|
+
sig do
|
|
151
|
+
params(
|
|
152
|
+
instance: DecoratedInstance,
|
|
153
|
+
prop: T.any(String, Symbol),
|
|
154
|
+
rules: Rules
|
|
155
|
+
)
|
|
156
|
+
.returns(T.untyped)
|
|
157
|
+
.checked(:never)
|
|
158
|
+
end
|
|
159
|
+
def prop_get_if_set(instance, prop, rules=prop_rules(prop))
|
|
160
|
+
instance.instance_variable_get(rules[:accessor_key])
|
|
161
|
+
end
|
|
162
|
+
alias_method :get, :prop_get_if_set # Alias for backwards compatibility
|
|
163
|
+
|
|
181
164
|
# checked(:never) - O(prop accesses)
|
|
182
165
|
sig do
|
|
183
166
|
params(
|
|
@@ -246,9 +229,10 @@ class T::Props::Decorator
|
|
|
246
229
|
nil
|
|
247
230
|
end
|
|
248
231
|
|
|
249
|
-
|
|
232
|
+
# Used to validate both prop names and serialized forms
|
|
233
|
+
sig {params(name: T.any(Symbol, String)).void}
|
|
250
234
|
private def validate_prop_name(name)
|
|
251
|
-
if name
|
|
235
|
+
if !name.match?(/\A[A-Za-z_][A-Za-z0-9_-]*\z/)
|
|
252
236
|
raise ArgumentError.new("Invalid prop name in #{@class.name}: #{name}")
|
|
253
237
|
end
|
|
254
238
|
end
|
data/lib/types/props/optional.rb
CHANGED
|
@@ -34,13 +34,6 @@ module T::Props::Optional::DecoratorMethods
|
|
|
34
34
|
|
|
35
35
|
def prop_optional?(prop); prop_rules(prop)[:fully_optional]; end
|
|
36
36
|
|
|
37
|
-
def mutate_prop_backdoor!(prop, key, value)
|
|
38
|
-
rules = props.fetch(prop)
|
|
39
|
-
rules = rules.merge(key => value)
|
|
40
|
-
compute_derived_rules(rules)
|
|
41
|
-
@props = props.merge(prop => rules.freeze).freeze
|
|
42
|
-
end
|
|
43
|
-
|
|
44
37
|
def compute_derived_rules(rules)
|
|
45
38
|
rules[:fully_optional] = !T::Props::Utils.need_nil_write_check?(rules)
|
|
46
39
|
rules[:need_nil_read_check] = T::Props::Utils.need_nil_read_check?(rules)
|
|
@@ -344,7 +344,7 @@ module T::Props::Serializable::DecoratorMethods
|
|
|
344
344
|
private_constant :EMPTY_EXTRA_PROPS
|
|
345
345
|
|
|
346
346
|
def extra_props(instance)
|
|
347
|
-
|
|
347
|
+
instance.instance_variable_get(:@_extra_props) || EMPTY_EXTRA_PROPS
|
|
348
348
|
end
|
|
349
349
|
|
|
350
350
|
# @override T::Props::PrettyPrintable
|
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.5316
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-01-
|
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|