sorbet-runtime 0.5.11226 → 0.5.11247
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/compatibility_patches.rb +1 -1
- data/lib/types/configuration.rb +1 -1
- data/lib/types/private/methods/_methods.rb +4 -4
- data/lib/types/private/methods/signature.rb +1 -2
- data/lib/types/private/methods/signature_validation.rb +3 -4
- data/lib/types/props/decorator.rb +1 -1
- data/lib/types/props/has_lazily_specialized_methods.rb +2 -0
- data/lib/types/props/private/deserializer_generator.rb +4 -1
- data/lib/types/props/serializable.rb +7 -1
- data/lib/types/types/proc.rb +3 -3
- data/lib/types/types/simple.rb +5 -0
- data/lib/types/types/typed_enumerable.rb +1 -1
- data/lib/types/utils.rb +4 -2
- metadata +15 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b83bceb98363dff65049cf85bf3f215f9ed521af33b79150f19ccf6358f540d8
|
4
|
+
data.tar.gz: 6ffa150d2caf6b39981073a4793a2b63e97e4e3446ca94117ed140824e9236b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a41476adf9ac14a97e2c5a518d4b8d19b7d21c337b355994773e3c2e8dddf6331c1f4b50baea804a8a725c6896bafd6140156dc15f92c696d99774e7e08ab72f
|
7
|
+
data.tar.gz: d2786e75ce070b86cd76ea31daa2fa8898c3d3811da1e8db5e49e5196352bdd2b67e3ca1232958bc08e2c24c1c196fc6013faadacbd620739131d046880152a5
|
@@ -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
|
data/lib/types/configuration.rb
CHANGED
@@ -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
|
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
|
-
|
64
|
-
|
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
|
-
|
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.
|
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")
|
data/lib/types/types/proc.rb
CHANGED
@@ -14,9 +14,9 @@ module T::Types
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def arg_types
|
17
|
-
@arg_types ||= @inner_arg_types.
|
18
|
-
|
19
|
-
end
|
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
|
data/lib/types/types/simple.rb
CHANGED
@@ -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
|
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
|
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.
|
4
|
+
version: 0.5.11247
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-10 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:
|
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:
|
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.
|
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.
|
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
|
@@ -151,7 +137,7 @@ dependencies:
|
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: 1.5.3
|
153
139
|
description: Sorbet's runtime type checking component
|
154
|
-
email:
|
140
|
+
email:
|
155
141
|
executables: []
|
156
142
|
extensions: []
|
157
143
|
extra_rdoc_files: []
|
@@ -248,7 +234,7 @@ licenses:
|
|
248
234
|
- Apache-2.0
|
249
235
|
metadata:
|
250
236
|
source_code_uri: https://github.com/sorbet/sorbet
|
251
|
-
post_install_message:
|
237
|
+
post_install_message:
|
252
238
|
rdoc_options: []
|
253
239
|
require_paths:
|
254
240
|
- lib
|
@@ -263,8 +249,8 @@ 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
|
267
|
-
signing_key:
|
252
|
+
rubygems_version: 3.5.3
|
253
|
+
signing_key:
|
268
254
|
specification_version: 4
|
269
255
|
summary: Sorbet runtime
|
270
256
|
test_files: []
|