sorbet-runtime 0.5.10802 → 0.5.10804

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5004ef6b79f17839bdaeba7d64017c3877849a37a767cfb4c3a941b295336607
4
- data.tar.gz: a47811314ee8449d9ca2c13b1e25391e8b20600a8b633b57e22a036ad5d4a1f0
3
+ metadata.gz: fa7a0490c3f7444ff040bb55e99d4fb52ee3943c97bd873427c52d58a67dee92
4
+ data.tar.gz: c2475595abbccc6900c35cb0747dc872ffc5fd0b8043d955a53bc8b5ecb6e13d
5
5
  SHA512:
6
- metadata.gz: 3a9726cb3e08bf0c98ad3a54f8326309a9981b4e2de2fcde58bd4a81181f9d38c52120f8e4f8abdc90df6b7b4997139a8bd8703ec8351df90b060cdb1959e9a1
7
- data.tar.gz: 00e90a39ee3784b72a8a36d98c53a7172b909da815403bf1a9b08e2301d8995c8f86b5045a5867610583cbd7a59b5b39d24e8139289a31d889880e32e9dc35d6
6
+ metadata.gz: b9367983c2a15754f5a2b39de9238d8d9ae387a6b1964edbd60e9d4f084877cd01a24a17095bc17dbb675b42f9b172f88f8a84560d585cc5af02f14e6bf83f9c
7
+ data.tar.gz: 65b7e38725846375455d4bef55314cc6e795a48c72761e9a24d2cd86764855e99351c93fa1beb59e62dc42f6f4c941853a8ddc15549532e7e2c78b065a7c706d
@@ -179,15 +179,7 @@ class T::Private::Methods::Signature
179
179
  kwargs = EMPTY_HASH
180
180
  end
181
181
 
182
- arg_types = @arg_types
183
-
184
- if @has_rest
185
- rest_count = args_length - @arg_types.length
186
- rest_count = 0 if rest_count.negative?
187
-
188
- arg_types += [[@rest_name, @rest_type]] * rest_count
189
-
190
- elsif (args_length < @req_arg_count) || (args_length > @arg_types.length)
182
+ if !@has_rest && ((args_length < @req_arg_count) || (args_length > @arg_types.length))
191
183
  expected_str = @req_arg_count.to_s
192
184
  if @arg_types.length != @req_arg_count
193
185
  expected_str += "..#{@arg_types.length}"
@@ -197,10 +189,23 @@ class T::Private::Methods::Signature
197
189
 
198
190
  begin
199
191
  it = 0
200
- while it < args_length
201
- yield arg_types[it][0], args[it], arg_types[it][1]
192
+
193
+ # Process given pre-rest args. When there are no rest args,
194
+ # this is just the given number of args.
195
+ while it < args_length && it < @arg_types.length
196
+ yield @arg_types[it][0], args[it], @arg_types[it][1]
202
197
  it += 1
203
198
  end
199
+
200
+ if @has_rest
201
+ rest_count = args_length - @arg_types.length
202
+ rest_count = 0 if rest_count.negative?
203
+
204
+ rest_count.times do
205
+ yield @rest_name, args[it], @rest_type
206
+ it += 1
207
+ end
208
+ end
204
209
  end
205
210
 
206
211
  kwargs.each do |name, val|
@@ -208,6 +213,7 @@ class T::Private::Methods::Signature
208
213
  if !type && @has_keyrest
209
214
  type = @keyrest_type
210
215
  end
216
+
211
217
  yield name, val, type if type
212
218
  end
213
219
  end
@@ -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
- ].map {|k| [k, true]}.to_h.freeze, T::Hash[Symbol, T::Boolean])
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 = rules.merge(
362
- # TODO: The type of this element is confusing. We should refactor so that
363
- # it can be always `type_object` (a PropType) or always `cls` (a Module)
364
- type: type,
365
- type_object: type_object,
366
- accessor_key: "@#{name}".to_sym,
367
- sensitivity: sensitivity_and_pii[:sensitivity],
368
- pii: sensitivity_and_pii[:pii],
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.10802
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-04 00:00:00.000000000 Z
11
+ date: 2023-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest