sorbet-runtime 0.5.10594 → 0.5.10626
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sorbet-runtime.rb +1 -0
- data/lib/types/_types.rb +10 -0
- data/lib/types/private/methods/_methods.rb +6 -1
- data/lib/types/private/methods/decl_builder.rb +16 -2
- data/lib/types/props/_props.rb +2 -2
- data/lib/types/types/typed_enumerable.rb +5 -0
- data/lib/types/types/typed_enumerator_chain.rb +41 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2df0fc9175dca7fadcaeeaf9d1c735bcc0c6cb3b74a1856f98fc86123da5759
|
4
|
+
data.tar.gz: 80f82b3b9fa004b847e4dfe3a13a55c7fb45981e87ae3e69f55c70b391e55b91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d1188622facbefc09b70006e296d9d7f8b5c440622c3dea5671b57a38474c70298c57187c1a60576be4c058fe9f3b053501332e148f02e4b0ad7213047c2558
|
7
|
+
data.tar.gz: d59e5d320de7676f9a902a0b9f0f1e70e31bc5d2096f00b3ce6784772fbb5ad0a119cc348dfb4baa3fbf1661322537f039f0f8b225ef30744335cf9c53dda746
|
data/lib/sorbet-runtime.rb
CHANGED
@@ -45,6 +45,7 @@ require_relative 'types/types/t_enum'
|
|
45
45
|
require_relative 'types/types/type_parameter'
|
46
46
|
require_relative 'types/types/typed_array'
|
47
47
|
require_relative 'types/types/typed_enumerator'
|
48
|
+
require_relative 'types/types/typed_enumerator_chain'
|
48
49
|
require_relative 'types/types/typed_enumerator_lazy'
|
49
50
|
require_relative 'types/types/typed_hash'
|
50
51
|
require_relative 'types/types/typed_range'
|
data/lib/types/_types.rb
CHANGED
@@ -324,6 +324,16 @@ module T
|
|
324
324
|
end
|
325
325
|
end
|
326
326
|
end
|
327
|
+
|
328
|
+
module Chain
|
329
|
+
def self.[](type)
|
330
|
+
if type.is_a?(T::Types::Untyped)
|
331
|
+
T::Types::TypedEnumeratorChain::Untyped.new
|
332
|
+
else
|
333
|
+
T::Types::TypedEnumeratorChain.new(type)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
327
337
|
end
|
328
338
|
|
329
339
|
module Range
|
@@ -117,6 +117,11 @@ module T::Private::Methods
|
|
117
117
|
@signatures_by_method[key]
|
118
118
|
end
|
119
119
|
|
120
|
+
# Fetch the directory name of the file that defines the `T::Private` constant and
|
121
|
+
# add a trailing slash to allow us to match it as a directory prefix.
|
122
|
+
SORBET_RUNTIME_LIB_PATH = File.dirname(T.const_source_location(:Private).first) + File::SEPARATOR
|
123
|
+
private_constant :SORBET_RUNTIME_LIB_PATH
|
124
|
+
|
120
125
|
# when target includes a module with instance methods source_method_names, ensure there is zero intersection between
|
121
126
|
# the final instance methods of target and source_method_names. so, for every m in source_method_names, check if there
|
122
127
|
# is already a method defined on one of target_ancestors with the same name that is final.
|
@@ -158,7 +163,7 @@ module T::Private::Methods
|
|
158
163
|
|
159
164
|
definition_file, definition_line = T::Private::Methods.signature_for_method(ancestor.instance_method(method_name)).method.source_location
|
160
165
|
is_redefined = target == ancestor
|
161
|
-
caller_loc = caller_locations&.find {|l| !l.to_s.
|
166
|
+
caller_loc = caller_locations&.find {|l| !l.to_s.start_with?(SORBET_RUNTIME_LIB_PATH)}
|
162
167
|
extra_info = "\n"
|
163
168
|
if caller_loc
|
164
169
|
extra_info = (is_redefined ? "Redefined" : "Overridden") + " here: #{caller_loc.path}:#{caller_loc.lineno}\n"
|
@@ -32,15 +32,29 @@ module T::Private::Methods
|
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
|
-
def params(**params)
|
35
|
+
def params(*unused_positional_params, **params)
|
36
36
|
check_live!
|
37
37
|
if !decl.params.equal?(ARG_NOT_PROVIDED)
|
38
38
|
raise BuilderError.new("You can't call .params twice")
|
39
39
|
end
|
40
40
|
|
41
|
+
if unused_positional_params.any?
|
42
|
+
some_or_only = params.any? ? "some" : "only"
|
43
|
+
raise BuilderError.new(<<~MSG)
|
44
|
+
'params' was called with #{some_or_only} positional arguments, but it needs to be called with keyword arguments.
|
45
|
+
The keyword arguments' keys must match the name and order of the method's parameters.
|
46
|
+
MSG
|
47
|
+
end
|
48
|
+
|
41
49
|
if params.empty?
|
42
|
-
raise BuilderError.new(
|
50
|
+
raise BuilderError.new(<<~MSG)
|
51
|
+
'params' was called without any arguments, but it needs to be called with keyword arguments.
|
52
|
+
The keyword arguments' keys must match the name and order of the method's parameters.
|
53
|
+
|
54
|
+
Omit 'params' entirely for methods with no parameters.
|
55
|
+
MSG
|
43
56
|
end
|
57
|
+
|
44
58
|
decl.params = params
|
45
59
|
|
46
60
|
self
|
data/lib/types/props/_props.rb
CHANGED
@@ -139,9 +139,9 @@ module T::Props
|
|
139
139
|
end
|
140
140
|
|
141
141
|
if cls_or_args.is_a?(Hash)
|
142
|
-
self.prop(name, cls_or_args.merge(immutable: true))
|
142
|
+
self.prop(name, **cls_or_args.merge(immutable: true))
|
143
143
|
else
|
144
|
-
self.prop(name, cls_or_args, args.merge(immutable: true))
|
144
|
+
self.prop(name, cls_or_args, **args.merge(immutable: true))
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -54,6 +54,9 @@ module T::Types
|
|
54
54
|
when Enumerator::Lazy
|
55
55
|
# Enumerators can be unbounded: see `[:foo, :bar].cycle`
|
56
56
|
true
|
57
|
+
when Enumerator::Chain
|
58
|
+
# Enumerators can be unbounded: see `[:foo, :bar].cycle`
|
59
|
+
true
|
57
60
|
when Enumerator
|
58
61
|
# Enumerators can be unbounded: see `[:foo, :bar].cycle`
|
59
62
|
true
|
@@ -145,6 +148,8 @@ module T::Types
|
|
145
148
|
end
|
146
149
|
when Enumerator::Lazy
|
147
150
|
T::Enumerator::Lazy[type_from_instances(obj)]
|
151
|
+
when Enumerator::Chain
|
152
|
+
T::Enumerator::Chain[type_from_instances(obj)]
|
148
153
|
when Enumerator
|
149
154
|
T::Enumerator[type_from_instances(obj)]
|
150
155
|
when Set
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# typed: true
|
3
|
+
|
4
|
+
module T::Types
|
5
|
+
class TypedEnumeratorChain < TypedEnumerable
|
6
|
+
attr_reader :type
|
7
|
+
|
8
|
+
def underlying_class
|
9
|
+
Enumerator::Chain
|
10
|
+
end
|
11
|
+
|
12
|
+
# overrides Base
|
13
|
+
def name
|
14
|
+
"T::Enumerator::Chain[#{@type.name}]"
|
15
|
+
end
|
16
|
+
|
17
|
+
# overrides Base
|
18
|
+
def recursively_valid?(obj)
|
19
|
+
obj.is_a?(Enumerator::Chain) && super
|
20
|
+
end
|
21
|
+
|
22
|
+
# overrides Base
|
23
|
+
def valid?(obj)
|
24
|
+
obj.is_a?(Enumerator::Chain)
|
25
|
+
end
|
26
|
+
|
27
|
+
def new(*args, &blk)
|
28
|
+
T.unsafe(Enumerator::Chain).new(*args, &blk)
|
29
|
+
end
|
30
|
+
|
31
|
+
class Untyped < TypedEnumeratorChain
|
32
|
+
def initialize
|
33
|
+
super(T.untyped)
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid?(obj)
|
37
|
+
obj.is_a?(Enumerator::Chain)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
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.10626
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- lib/types/types/typed_array.rb
|
235
235
|
- lib/types/types/typed_enumerable.rb
|
236
236
|
- lib/types/types/typed_enumerator.rb
|
237
|
+
- lib/types/types/typed_enumerator_chain.rb
|
237
238
|
- lib/types/types/typed_enumerator_lazy.rb
|
238
239
|
- lib/types/types/typed_hash.rb
|
239
240
|
- lib/types/types/typed_range.rb
|