sorbet-runtime 0.5.11238 → 0.5.11249

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72adb8b8c4d4bf8d4001df6b67cd9141af0c185e16cc9c061d0dfd57f2750043
4
- data.tar.gz: f010834fde3fa8f89c3efd3dfd856e78268df7338bb512e574b38fa30dbbd989
3
+ metadata.gz: a50e5b3f92165c1b8bc41be7ed62e757a8698c147a70025bcb1e9b167ca36b63
4
+ data.tar.gz: 8e235f8ae50375d6d104af4bbc601c9377bd744a33b8bc98b2bcd0dbea6778a1
5
5
  SHA512:
6
- metadata.gz: 3bff53ced52d1e3159f7a0555af87c0d580f5ba1e0a836e8b9f4b9a1288f17eb8f921d81947c22f3715286d5ac4e38ee1f355dcbf87e134b4c9e10178aaff157
7
- data.tar.gz: 76fa2229acd867fa02a2d5a4452b63a9a74e9b0e5eee22b7f68c015c16e266106d3ed97f5dea1f3e2aa7a9efbc5383c959486b482ac974c6d362fbb8c096d93e
6
+ metadata.gz: bf8c904ce5f96cbe0e2e7aee6fbec22128d63e66e41520fe2bddbcc2a00a53d7bb9f05b876a3438b198f147201bdccdcedb7712eeb15b6c337c5608ddb4ac7fe
7
+ data.tar.gz: 6b70175ecb9c283bff49cf81edd92d03835edb4bb84c63e92f2eac1b9823a4e098c4c58dc9c14a40e8e9aedb3e0d1cf44950b182a148545c8862cc52b4921463
@@ -38,7 +38,7 @@ if defined? ::RSpec::Mocks
38
38
 
39
39
  module MethodDoubleExtensions
40
40
  def initialize(object, method_name, proxy)
41
- if ::Kernel.instance_method(:respond_to?).bind(object).call(method_name, true)
41
+ if ::Kernel.instance_method(:respond_to?).bind(object).call(method_name, true) # rubocop:disable Performance/BindCall
42
42
  method = ::RSpec::Support.method_handle_for(object, method_name)
43
43
  T::Private::Methods.maybe_run_sig_block_for_method(method)
44
44
  end
@@ -451,7 +451,7 @@ module T::Configuration
451
451
  @default_module_name_mangler = if T::Configuration::AT_LEAST_RUBY_2_7
452
452
  ->(type) {MODULE_NAME.bind_call(type)}
453
453
  else
454
- ->(type) {MODULE_NAME.bind(type).call}
454
+ ->(type) {MODULE_NAME.bind(type).call} # rubocop:disable Performance/BindCall
455
455
  end
456
456
 
457
457
  @module_name_mangler = nil
@@ -273,7 +273,7 @@ module T::Private::Methods
273
273
  elsif T::Configuration::AT_LEAST_RUBY_2_7
274
274
  original_method.bind_call(self, *args, &blk)
275
275
  else
276
- original_method.bind(self).call(*args, &blk)
276
+ original_method.bind(self).call(*args, &blk) # rubocop:disable Performance/BindCall
277
277
  end
278
278
  end
279
279
  end
@@ -514,7 +514,7 @@ module T::Private::Methods
514
514
  if T::Configuration::AT_LEAST_RUBY_2_7
515
515
  old_included.bind_call(self, arg)
516
516
  else
517
- old_included.bind(self).call(arg)
517
+ old_included.bind(self).call(arg) # rubocop:disable Performance/BindCall
518
518
  end
519
519
  ::T::Private::Methods._hook_impl(arg, false, self)
520
520
  end
@@ -522,7 +522,7 @@ module T::Private::Methods
522
522
  if T::Configuration::AT_LEAST_RUBY_2_7
523
523
  old_extended.bind_call(self, arg)
524
524
  else
525
- old_extended.bind(self).call(arg)
525
+ old_extended.bind(self).call(arg) # rubocop:disable Performance/BindCall
526
526
  end
527
527
  ::T::Private::Methods._hook_impl(arg, true, self)
528
528
  end
@@ -530,7 +530,7 @@ module T::Private::Methods
530
530
  if T::Configuration::AT_LEAST_RUBY_2_7
531
531
  old_inherited.bind_call(self, arg)
532
532
  else
533
- old_inherited.bind(self).call(arg)
533
+ old_inherited.bind(self).call(arg) # rubocop:disable Performance/BindCall
534
534
  end
535
535
  ::T::Private::Methods._hook_impl(arg, false, self)
536
536
  end
@@ -73,8 +73,7 @@ class T::Private::Methods::Signature
73
73
  param_names = parameters.map {|_, name| name}
74
74
  missing_names = param_names - raw_arg_types.keys
75
75
  raise "The declaration for `#{method.name}` is missing parameter(s): #{missing_names.join(', ')}"
76
- elsif parameters.length == raw_arg_types.size
77
- else
76
+ elsif parameters.length != raw_arg_types.size
78
77
  param_names = parameters.map {|_, name| name}
79
78
  has_extra_names = parameters.count {|_, name| raw_arg_types.key?(name)} < raw_arg_types.size
80
79
  if has_extra_names
@@ -59,10 +59,9 @@ module T::Private::Methods::SignatureValidation
59
59
  # `{ new(): AbstractClass }`. We may want to consider building some
60
60
  # analogue to `T.class_of` in the future that works like this `{new():
61
61
  # ...}` type.
62
- if signature.method_name == :initialize && signature.method.owner.is_a?(Class)
63
- if signature.mode == Modes.standard
64
- return
65
- end
62
+ if signature.method_name == :initialize && signature.method.owner.is_a?(Class) &&
63
+ signature.mode == Modes.standard
64
+ return
66
65
  end
67
66
 
68
67
  super_method = signature.method.super_method
@@ -117,7 +117,9 @@ module T::Props
117
117
  def eagerly_define_lazy_methods!
118
118
  return if lazily_defined_methods.empty?
119
119
 
120
+ # rubocop:disable Style/StringConcatenation
120
121
  source = "# frozen_string_literal: true\n" + lazily_defined_methods.values.map(&:call).map(&:to_s).join("\n\n")
122
+ # rubocop:enable Style/StringConcatenation
121
123
 
122
124
  cls = decorated_class
123
125
  cls.class_eval(source)
@@ -137,7 +137,10 @@ module T::Props
137
137
  when ApplyPrimitiveDefault
138
138
  literal = default.default
139
139
  case literal
140
- when String, Integer, Symbol, Float, TrueClass, FalseClass, NilClass
140
+ # `Float` is intentionally left out here because `.inspect` does not produce the correct code
141
+ # representation for non-finite values like `Float::INFINITY` and `Float::NAN` and it's not totally
142
+ # clear that it won't cause issues with floating point precision.
143
+ when String, Integer, Symbol, TrueClass, FalseClass, NilClass
141
144
  literal.inspect
142
145
  else
143
146
  "self.class.decorator.props_with_defaults.fetch(#{prop.inspect}).default"
@@ -264,7 +264,13 @@ module T::Props::Serializable::DecoratorMethods
264
264
  line_label = error.backtrace.find {|l| l.end_with?("in `#{generated_method}'")}
265
265
  return unless line_label
266
266
 
267
- line_num = line_label.split(':')[1]&.to_i
267
+ line_num = if line_label.start_with?("(eval)")
268
+ # (eval):13:in `__t_props_generated_serialize'
269
+ line_label.split(':')[1]&.to_i
270
+ else
271
+ # (eval at /Users/jez/stripe/sorbet/gems/sorbet-runtime/lib/types/props/has_lazily_specialized_methods.rb:65):13:in `__t_props_generated_serialize'
272
+ line_label.split(':')[2]&.to_i
273
+ end
268
274
  return unless line_num
269
275
 
270
276
  source_lines = self.send(generate_source_method).split("\n")
@@ -14,9 +14,9 @@ module T::Types
14
14
  end
15
15
 
16
16
  def arg_types
17
- @arg_types ||= @inner_arg_types.map do |key, raw_type|
18
- [key, T::Utils.coerce(raw_type)]
19
- end.to_h
17
+ @arg_types ||= @inner_arg_types.transform_values do |raw_type|
18
+ T::Utils.coerce(raw_type)
19
+ end
20
20
  end
21
21
 
22
22
  def returns
@@ -23,7 +23,12 @@ module T::Types
23
23
  #
24
24
  # `name` isn't normally a hot path for types, but it is used in initializing a T::Types::Union,
25
25
  # and so in `T.nilable`, and so in runtime constructions like `x = T.let(nil, T.nilable(Integer))`.
26
+ #
27
+ # Care more about back compat than we do about performance here.
28
+ # Once 2.6 is well in the rear view mirror, we can replace this.
29
+ # rubocop:disable Performance/BindCall
26
30
  @name ||= (NAME_METHOD.bind(@raw_type).call || @raw_type.name).freeze
31
+ # rubocop:enable Performance/BindCall
27
32
  end
28
33
 
29
34
  # overrides Base
@@ -172,7 +172,7 @@ module T::Types
172
172
  if T::Configuration::AT_LEAST_RUBY_2_7
173
173
  Object.instance_method(:class).bind_call(obj)
174
174
  else
175
- Object.instance_method(:class).bind(obj).call
175
+ Object.instance_method(:class).bind(obj).call # rubocop:disable Performance/BindCall
176
176
  end
177
177
  end
178
178
  end
data/lib/types/utils.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  module T::Utils
5
5
  module Private
6
6
  def self.coerce_and_check_module_types(val, check_val, check_module_type)
7
+ # rubocop:disable Style/CaseLikeIf
7
8
  if val.is_a?(T::Types::Base)
8
9
  if val.is_a?(T::Private::Types::TypeAlias)
9
10
  val.aliased_type
@@ -31,6 +32,7 @@ module T::Utils
31
32
  raise "Invalid value for type constraint. Must be an #{T::Types::Base}, a " \
32
33
  "class/module, or an array. Got a `#{val.class}`."
33
34
  end
35
+ # rubocop:enable Style/CaseLikeIf
34
36
  end
35
37
  end
36
38
 
@@ -173,7 +175,7 @@ module T::Utils
173
175
  def self.get_type_info(prop_type)
174
176
  if prop_type.is_a?(T::Types::Union)
175
177
  non_nilable_type = prop_type.unwrap_nilable
176
- if non_nilable_type&.is_a?(T::Types::Simple)
178
+ if non_nilable_type.is_a?(T::Types::Simple)
177
179
  non_nilable_type = non_nilable_type.raw_type
178
180
  end
179
181
  TypeInfo.new(true, non_nilable_type)
@@ -188,7 +190,7 @@ module T::Utils
188
190
  def self.get_underlying_type(prop_type)
189
191
  if prop_type.is_a?(T::Types::Union)
190
192
  non_nilable_type = prop_type.unwrap_nilable
191
- if non_nilable_type&.is_a?(T::Types::Simple)
193
+ if non_nilable_type.is_a?(T::Types::Simple)
192
194
  non_nilable_type = non_nilable_type.raw_type
193
195
  end
194
196
  non_nilable_type || prop_type
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.11238
4
+ version: 0.5.11249
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-09 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -56,30 +56,30 @@ dependencies:
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.90.0
61
+ version: 1.57.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.90.0
68
+ version: 1.57.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 1.8.0
75
+ version: 1.13.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 1.8.0
82
+ version: 1.13.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: concurrent-ruby
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: parser
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 2.7.1
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 2.7.1
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: subprocess
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -263,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
249
  - !ruby/object:Gem::Version
264
250
  version: '0'
265
251
  requirements: []
266
- rubygems_version: 3.3.7
252
+ rubygems_version: 3.5.3
267
253
  signing_key:
268
254
  specification_version: 4
269
255
  summary: Sorbet runtime