sorbet-runtime 0.5.9167 → 0.5.9189

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: 515f42038119f8f98f56e0b942195ccd75e2b6ec406ae326c2dd1916e8b963e5
4
- data.tar.gz: ee462e33c5d3a66e6501d0546164023de83ebf98c0602556936a19851cd44aef
3
+ metadata.gz: a93e070231c5c86c5825e5417d124f1fad4be4afab06c09ed5329b181bcb4fb1
4
+ data.tar.gz: 07b92443ed0e5abe32bb217b9d7e0416256b86aa19d481a203421ea26ba3abe8
5
5
  SHA512:
6
- metadata.gz: 57419c69a74269e39bb450e4d5db927a09266850641dab3a6f0f15927b17f576f97fe55587c0ecedf43a597bebc4d30ddcd1e3f5405fa5ede34698e9574316d3
7
- data.tar.gz: 26956a32d869e598183fea9473439a50ce875fce931448f2f28ca17e6ac59af561736c6a3b278478136f23dac0002edc490ebd343c61c8862e3827502597f6e3
6
+ metadata.gz: e7b4e250852b94e2a1e9e06a85e24aecc4dfef5457d19a3a556e7785c9e28e358b4be9e9b95c7ab4cca6fed8ace7eb85998b3b2bf483b29d78b1c12a113cced3
7
+ data.tar.gz: 00e7552c90712bc61f494c37a0a0a8404679f72a9d5c8ce745d9602f38ffa387823a190bf8c0f8b7b90ea7b2af00cfc249834d166309b31d7c782cd4339b86a0
data/lib/types/_types.rb CHANGED
@@ -82,8 +82,9 @@ module T
82
82
 
83
83
  # Constructs a type alias. Used to create a short name for a larger type. In Ruby this returns a
84
84
  # wrapper that contains a proc that is evaluated to get the underlying type. This syntax however
85
- # is needed for support by the static checker. Example usage:
85
+ # is needed for support by the static checker.
86
86
  #
87
+ # @example
87
88
  # NilableString = T.type_alias {T.nilable(String)}
88
89
  #
89
90
  # sig {params(arg: NilableString, default: String).returns(String)}
@@ -106,8 +107,9 @@ module T
106
107
  # References a type parameter which was previously defined with
107
108
  # `type_parameters`.
108
109
  #
109
- # This is used for generic methods. Example usage:
110
+ # This is used for generic methods.
110
111
  #
112
+ # @example
111
113
  # sig
112
114
  # .type_parameters(:U)
113
115
  # .params(
@@ -185,7 +187,7 @@ module T
185
187
  # cycle. However, we also don't actually need to do so; An untyped
186
188
  # identity method works just as well here.
187
189
  #
188
- # sig {params(value: T.untyped).returns(T.untyped)}
190
+ # `sig {params(value: T.untyped).returns(T.untyped)}`
189
191
  def self.unsafe(value)
190
192
  value
191
193
  end
@@ -206,7 +208,7 @@ module T
206
208
  # Intended to be used to promise sorbet that a given nilable value happens
207
209
  # to contain a non-nil value at this point.
208
210
  #
209
- # sig {params(arg: T.nilable(A)).returns(A)}
211
+ # `sig {params(arg: T.nilable(A)).returns(A)}`
210
212
  def self.must(arg)
211
213
  return arg if arg
212
214
  return arg if arg == false
@@ -130,12 +130,12 @@ module T::Configuration
130
130
  #
131
131
  # Parameters passed to value.call:
132
132
  #
133
- # @param [TypeError] error TypeError that was raised
134
- # @param [Hash] opts A hash containing contextual information on the error:
135
- # @option opts [String] :kind One of:
136
- # ['T.cast', 'T.let', 'T.bind', 'T.assert_type!', 'T.must', 'T.absurd']
137
- # @option opts [Object, nil] :type Expected param/return value type
138
- # @option opts [Object] :value Actual param/return value
133
+ # @param [TypeError] error TypeError that was raised
134
+ # @param [Hash] opts A hash containing contextual information on the error:
135
+ # @option opts [String] :kind One of:
136
+ # ['T.cast', 'T.let', 'T.bind', 'T.assert_type!', 'T.must', 'T.absurd']
137
+ # @option opts [Object, nil] :type Expected param/return value type
138
+ # @option opts [Object] :value Actual param/return value
139
139
  #
140
140
  # @example
141
141
  # T::Configuration.inline_type_error_handler = lambda do |error, opts|
@@ -179,8 +179,8 @@ module T::Configuration
179
179
  #
180
180
  # Parameters passed to value.call:
181
181
  #
182
- # @param [StandardError] error The error that was raised
183
- # @param [Thread::Backtrace::Location] location Location of the error
182
+ # @param [StandardError] error The error that was raised
183
+ # @param [Thread::Backtrace::Location] location Location of the error
184
184
  #
185
185
  # @example
186
186
  # T::Configuration.sig_builder_error_handler = lambda do |error, location|
@@ -221,16 +221,16 @@ module T::Configuration
221
221
  #
222
222
  # Parameters passed to value.call:
223
223
  #
224
- # @param [StandardError] error The error that was raised
225
- # @param [Hash] opts A hash containing contextual information on the error:
226
- # @option opts [Method, UnboundMethod] :method Method on which the signature build failed
227
- # @option opts [T::Private::Methods::Declaration] :declaration Method
228
- # signature declaration struct
229
- # @option opts [T::Private::Methods::Signature, nil] :signature Signature
230
- # that failed (nil if sig build failed before Signature initialization)
231
- # @option opts [T::Private::Methods::Signature, nil] :super_signature Super
232
- # method's signature (nil if method is not an override or super method
233
- # does not have a method signature)
224
+ # @param [StandardError] error The error that was raised
225
+ # @param [Hash] opts A hash containing contextual information on the error:
226
+ # @option opts [Method, UnboundMethod] :method Method on which the signature build failed
227
+ # @option opts [T::Private::Methods::Declaration] :declaration Method
228
+ # signature declaration struct
229
+ # @option opts [T::Private::Methods::Signature, nil] :signature Signature
230
+ # that failed (nil if sig build failed before Signature initialization)
231
+ # @option opts [T::Private::Methods::Signature, nil] :super_signature Super
232
+ # method's signature (nil if method is not an override or super method
233
+ # does not have a method signature)
234
234
  #
235
235
  # @example
236
236
  # T::Configuration.sig_validation_error_handler = lambda do |error, opts|
@@ -266,17 +266,17 @@ module T::Configuration
266
266
  #
267
267
  # Parameters passed to value.call:
268
268
  #
269
- # @param [T::Private::Methods::Signature] signature Signature that failed
270
- # @param [Hash] opts A hash containing contextual information on the error:
271
- # @option opts [String] :message Error message
272
- # @option opts [String] :kind One of:
273
- # ['Parameter', 'Block parameter', 'Return value']
274
- # @option opts [Symbol] :name Param or block param name (nil for return
275
- # value)
276
- # @option opts [Object] :type Expected param/return value type
277
- # @option opts [Object] :value Actual param/return value
278
- # @option opts [Thread::Backtrace::Location] :location Location of the
279
- # caller
269
+ # @param [T::Private::Methods::Signature] signature Signature that failed
270
+ # @param [Hash] opts A hash containing contextual information on the error:
271
+ # @option opts [String] :message Error message
272
+ # @option opts [String] :kind One of:
273
+ # ['Parameter', 'Block parameter', 'Return value']
274
+ # @option opts [Symbol] :name Param or block param name (nil for return
275
+ # value)
276
+ # @option opts [Object] :type Expected param/return value type
277
+ # @option opts [Object] :value Actual param/return value
278
+ # @option opts [Thread::Backtrace::Location] :location Location of the
279
+ # caller
280
280
  #
281
281
  # @example
282
282
  # T::Configuration.call_validation_error_handler = lambda do |signature, opts|
@@ -307,8 +307,8 @@ module T::Configuration
307
307
  #
308
308
  # Parameters passed to value.call:
309
309
  #
310
- # @param [String] str Message to be logged
311
- # @param [Hash] extra A hash containing additional parameters to be passed along to the logger.
310
+ # @param [String] str Message to be logged
311
+ # @param [Hash] extra A hash containing additional parameters to be passed along to the logger.
312
312
  #
313
313
  # @example
314
314
  # T::Configuration.log_info_handler = lambda do |str, extra|
@@ -341,8 +341,8 @@ module T::Configuration
341
341
  #
342
342
  # Parameters passed to value.call:
343
343
  #
344
- # @param [String] str Assertion message
345
- # @param [Hash] extra A hash containing additional parameters to be passed along to the handler.
344
+ # @param [String] str Assertion message
345
+ # @param [Hash] extra A hash containing additional parameters to be passed along to the handler.
346
346
  #
347
347
  # @example
348
348
  # T::Configuration.soft_assert_handler = lambda do |str, extra|
@@ -375,8 +375,8 @@ module T::Configuration
375
375
  #
376
376
  # Parameters passed to value.call:
377
377
  #
378
- # @param [String] str Assertion message
379
- # @param [Hash] extra A hash containing additional parameters to be passed along to the handler.
378
+ # @param [String] str Assertion message
379
+ # @param [Hash] extra A hash containing additional parameters to be passed along to the handler.
380
380
  #
381
381
  # @example
382
382
  # T::Configuration.hard_assert_handler = lambda do |str, extra|
@@ -402,7 +402,7 @@ module T::Configuration
402
402
  # Set a list of class strings that are to be considered scalar.
403
403
  # (pass nil to reset to default behavior)
404
404
  #
405
- # @param [String] value Class name.
405
+ # @param [String] values Class name.
406
406
  #
407
407
  # @example
408
408
  # T::Configuration.scalar_types = ["NilClass", "TrueClass", "FalseClass", ...]
@@ -455,7 +455,7 @@ module T::Configuration
455
455
  # to names in generated code. Used by the runtime implementation
456
456
  # associated with `--stripe-packages` mode.
457
457
  #
458
- # @param [Lambda, Proc, nil] value Proc that converts a type (Class/Module)
458
+ # @param [Lambda, Proc, nil] handler Proc that converts a type (Class/Module)
459
459
  # to a String (pass nil to reset to default behavior)
460
460
  def self.module_name_mangler=(handler)
461
461
  @module_name_mangler = handler
@@ -464,7 +464,7 @@ module T::Configuration
464
464
  # Set to a PII handler function. This will be called with the `sensitivity:`
465
465
  # annotations on things that use `T::Props` and can modify them ahead-of-time.
466
466
  #
467
- # @param [Lambda, Proc, nil] value Proc that takes a hash mapping symbols to the
467
+ # @param [Lambda, Proc, nil] handler Proc that takes a hash mapping symbols to the
468
468
  # prop values. Pass nil to avoid changing `sensitivity:` annotations.
469
469
  def self.normalize_sensitivity_and_pii_handler=(handler)
470
470
  @sensitivity_and_pii_handler = handler
@@ -480,7 +480,7 @@ module T::Configuration
480
480
  # `nil` and will raise an exception when the redacted version of a prop is
481
481
  # accessed.
482
482
  #
483
- # @param [Lambda, Proc, nil] value Proc that converts a value into its
483
+ # @param [Lambda, Proc, nil] handler Proc that converts a value into its
484
484
  # redacted version according to the spec passed as the second argument.
485
485
  def self.redaction_handler=(handler)
486
486
  @redaction_handler = handler
@@ -493,7 +493,7 @@ module T::Configuration
493
493
  # Set to a function which can get the 'owner' of a class. This is
494
494
  # used in reporting deserialization errors
495
495
  #
496
- # @param [Lambda, Proc, nil] value Proc that takes a class and
496
+ # @param [Lambda, Proc, nil] handler Proc that takes a class and
497
497
  # produces its owner, or `nil` if it does not have one.
498
498
  def self.class_owner_finder=(handler)
499
499
  @class_owner_finder = handler
data/lib/types/enum.rb CHANGED
@@ -47,7 +47,7 @@ class T::Enum
47
47
  SerializedVal = T.type_alias {T.untyped}
48
48
  private_constant :SerializedVal
49
49
 
50
- ## Enum class methods ##
50
+ ### Enum class methods ###
51
51
  sig {returns(T::Array[T.attached_class])}
52
52
  def self.values
53
53
  if @values.nil?
@@ -134,7 +134,7 @@ class T::Enum
134
134
  self.from_serialized(mongo_value)
135
135
  end
136
136
 
137
- ## Enum instance methods ##
137
+ ### Enum instance methods ###
138
138
 
139
139
  sig {returns(T.self_type)}
140
140
  def dup
@@ -243,7 +243,7 @@ class T::Enum
243
243
  )
244
244
  end
245
245
 
246
- ## Private implementation ##
246
+ ### Private implementation ###
247
247
 
248
248
  sig {params(serialized_val: SerializedVal).void}
249
249
  def initialize(serialized_val=nil)
@@ -156,7 +156,7 @@ class T::Private::Methods::Signature
156
156
  "#{@mode}_method"
157
157
  end
158
158
 
159
- # @return [Hash] a mapping like {arg_name: [val, type], ...}, for only those args actually present.
159
+ # @return [Hash] a mapping like `{arg_name: [val, type], ...}`, for only those args actually present.
160
160
  def each_args_value_type(args)
161
161
  # Manually split out args and kwargs based on ruby's behavior. Do not try to implement this by
162
162
  # getting ruby to determine the kwargs for you (e.g., by defining this method to take *args and
@@ -6,17 +6,17 @@
6
6
  class T::Private::Types::NotTyped < T::Types::Base
7
7
  ERROR_MESSAGE = "Validation is being done on a `NotTyped`. Please report to #dev-productivity."
8
8
 
9
- # @override Base
9
+ # overrides Base
10
10
  def name
11
11
  "<NOT-TYPED>"
12
12
  end
13
13
 
14
- # @override Base
14
+ # overrides Base
15
15
  def valid?(obj)
16
16
  raise ERROR_MESSAGE
17
17
  end
18
18
 
19
- # @override Base
19
+ # overrides Base
20
20
  private def subtype_of_single?(other)
21
21
  raise ERROR_MESSAGE
22
22
  end
@@ -9,17 +9,17 @@ class T::Private::Types::StringHolder < T::Types::Base
9
9
  @string = string
10
10
  end
11
11
 
12
- # @override Base
12
+ # overrides Base
13
13
  def name
14
14
  string
15
15
  end
16
16
 
17
- # @override Base
17
+ # overrides Base
18
18
  def valid?(obj)
19
19
  false
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  private def subtype_of_single?(other)
24
24
  false
25
25
  end
@@ -13,17 +13,17 @@ module T::Private::Types
13
13
  @aliased_type ||= T::Utils.coerce(@callable.call)
14
14
  end
15
15
 
16
- # @override Base
16
+ # overrides Base
17
17
  def name
18
18
  aliased_type.name
19
19
  end
20
20
 
21
- # @override Base
21
+ # overrides Base
22
22
  def recursively_valid?(obj)
23
23
  aliased_type.recursively_valid?(obj)
24
24
  end
25
25
 
26
- # @override Base
26
+ # overrides Base
27
27
  def valid?(obj)
28
28
  aliased_type.valid?(obj)
29
29
  end
@@ -17,17 +17,17 @@ class T::Private::Types::Void < T::Types::Base
17
17
  freeze
18
18
  end
19
19
 
20
- # @override Base
20
+ # overrides Base
21
21
  def name
22
22
  "<VOID>"
23
23
  end
24
24
 
25
- # @override Base
25
+ # overrides Base
26
26
  def valid?(obj)
27
27
  raise ERROR_MESSAGE
28
28
  end
29
29
 
30
- # @override Base
30
+ # overrides Base
31
31
  private def subtype_of_single?(other)
32
32
  raise ERROR_MESSAGE
33
33
  end
@@ -38,8 +38,6 @@ module T::Props
38
38
  @decorator = decorator_class.new(self)
39
39
  end
40
40
 
41
- # @!method self.prop(name, type, opts={})
42
- #
43
41
  # Define a new property. See {file:README.md} for some concrete
44
42
  # examples.
45
43
  #
@@ -50,7 +48,7 @@ module T::Props
50
48
  #
51
49
  # @param name [Symbol] The name of this property
52
50
  # @param cls [Class,T::Types::Base] The type of this
53
- # property. If the type is itself a {Document} subclass, this
51
+ # property. If the type is itself a `Document` subclass, this
54
52
  # property will be recursively serialized/deserialized.
55
53
  # @param rules [Hash] Options to control this property's behavior.
56
54
  # @option rules [T::Boolean,Symbol] :optional If `true`, this property
@@ -61,7 +59,7 @@ module T::Props
61
59
  # If `false`, when the property is missing/nil after deserialization, it
62
60
  # will be set to the default value (as defined by the `default` or
63
61
  # `factory` option) or will raise if they are not present.
64
- # Deprecated: For {Model}s, if `:optional` is set to the special value
62
+ # Deprecated: For `Model`s, if `:optional` is set to the special value
65
63
  # `:existing`, the property can be saved as nil even if it was
66
64
  # deserialized with a non-nil value. (Deprecated because there should
67
65
  # never be a need for this behavior; the new behavior of non-optional
@@ -69,7 +67,8 @@ module T::Props
69
67
  # @option rules [Array] :enum An array of legal values; The
70
68
  # property is required to take on one of those values.
71
69
  # @option rules [T::Boolean] :dont_store If true, this property will
72
- # not be saved on the hash resulting from {#serialize}
70
+ # not be saved on the hash resulting from
71
+ # {T::Props::Serializable#serialize}
73
72
  # @option rules [Object] :ifunset A value to be returned if this
74
73
  # property is requested but has never been set (is set to
75
74
  # `nil`). It is applied at property-access time, and never saved
@@ -93,10 +92,10 @@ module T::Props
93
92
  # class directly.
94
93
  #
95
94
  # @option rules [Object] :default A default value that will be set
96
- # by {#initialize} if none is provided in the initialization
95
+ # by `#initialize` if none is provided in the initialization
97
96
  # hash. This will not affect objects loaded by {.from_hash}.
98
97
  # @option rules [Proc] :factory A `Proc` that will be called to
99
- # generate an initial value for this prop on {#initialize}, if
98
+ # generate an initial value for this prop on `#initialize`, if
100
99
  # none is provided.
101
100
  # @option rules [T::Boolean] :immutable If true, this prop cannot be
102
101
  # modified after an instance is created or loaded from a hash.
@@ -116,8 +115,6 @@ module T::Props
116
115
  decorator.prop_defined(name, cls, rules)
117
116
  end
118
117
 
119
- # @!method validate_prop_value(propname, value)
120
- #
121
118
  # Validates the value of the specified prop. This method allows the caller to
122
119
  # validate a value for a prop without having to set the data on the instance.
123
120
  # Throws if invalid.
@@ -37,7 +37,7 @@ module T::Props
37
37
  # Given an instance of this type, serialize that into a scalar type
38
38
  # supported by T::Props.
39
39
  #
40
- # @param [Object] _instance
40
+ # @param [Object] instance
41
41
  # @return An instance of one of T::Configuration.scalar_types
42
42
  sig {abstract.params(instance: T.untyped).returns(T.untyped).checked(:never)}
43
43
  def serialize(instance); end
@@ -442,7 +442,7 @@ class T::Props::Decorator
442
442
  end
443
443
  end
444
444
 
445
- # Create "#{prop_name}_redacted" method
445
+ # Create `#{prop_name}_redacted` method
446
446
  sig do
447
447
  params(
448
448
  prop_name: Symbol,
@@ -325,7 +325,7 @@ module T::Props::Serializable::DecoratorMethods
325
325
  instance.instance_variable_get(:@_extra_props) || EMPTY_EXTRA_PROPS
326
326
  end
327
327
 
328
- # @override T::Props::PrettyPrintable
328
+ # overrides T::Props::PrettyPrintable
329
329
  private def inspect_instance_components(instance, multiline:, indent:)
330
330
  if (extra_props = extra_props(instance)) && !extra_props.empty?
331
331
  pretty_kvs = extra_props.map {|k, v| [k.to_sym, v.inspect]}
@@ -346,8 +346,6 @@ module T::Props::Serializable::ClassMethods
346
346
  @prop_by_serialized_forms ||= {}
347
347
  end
348
348
 
349
- # @!method self.from_hash(hash, strict)
350
- #
351
349
  # Allocate a new instance and call {#deserialize} to load a new
352
350
  # object from a hash.
353
351
  # @return [Serializable]
@@ -10,17 +10,17 @@ module T::Types
10
10
 
11
11
  def initialize(); end
12
12
 
13
- # @override Base
13
+ # overrides Base
14
14
  def name
15
15
  "T.attached_class"
16
16
  end
17
17
 
18
- # @override Base
18
+ # overrides Base
19
19
  def valid?(obj)
20
20
  true
21
21
  end
22
22
 
23
- # @override Base
23
+ # overrides Base
24
24
  private def subtype_of_single?(other)
25
25
  case other
26
26
  when AttachedClassType
@@ -10,17 +10,17 @@ module T::Types
10
10
  @type = type
11
11
  end
12
12
 
13
- # @override Base
13
+ # overrides Base
14
14
  def name
15
15
  "T.class_of(#{@type})"
16
16
  end
17
17
 
18
- # @override Base
18
+ # overrides Base
19
19
  def valid?(obj)
20
20
  obj.is_a?(Module) && obj <= @type
21
21
  end
22
22
 
23
- # @override Base
23
+ # overrides Base
24
24
  def subtype_of_single?(other)
25
25
  case other
26
26
  when ClassOf
@@ -30,7 +30,7 @@ module T::Types
30
30
  end
31
31
  end
32
32
 
33
- # @override Base
33
+ # overrides Base
34
34
  def describe_obj(obj)
35
35
  obj.inspect
36
36
  end
@@ -14,12 +14,12 @@ module T::Types
14
14
  @values = values
15
15
  end
16
16
 
17
- # @override Base
17
+ # overrides Base
18
18
  def valid?(obj)
19
19
  @values.member?(obj)
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  private def subtype_of_single?(other)
24
24
  case other
25
25
  when Enum
@@ -29,12 +29,12 @@ module T::Types
29
29
  end
30
30
  end
31
31
 
32
- # @override Base
32
+ # overrides Base
33
33
  def name
34
34
  "T.enum([#{@values.map(&:inspect).join(', ')}])"
35
35
  end
36
36
 
37
- # @override Base
37
+ # overrides Base
38
38
  def describe_obj(obj)
39
39
  obj.inspect
40
40
  end
@@ -12,12 +12,12 @@ module T::Types
12
12
  @types = types.map {|type| T::Utils.coerce(type)}
13
13
  end
14
14
 
15
- # @override Base
15
+ # overrides Base
16
16
  def name
17
17
  "[#{@types.join(', ')}]"
18
18
  end
19
19
 
20
- # @override Base
20
+ # overrides Base
21
21
  def recursively_valid?(obj)
22
22
  if obj.is_a?(Array) && obj.length == @types.length
23
23
  i = 0
@@ -33,7 +33,7 @@ module T::Types
33
33
  end
34
34
  end
35
35
 
36
- # @override Base
36
+ # overrides Base
37
37
  def valid?(obj)
38
38
  if obj.is_a?(Array) && obj.length == @types.length
39
39
  i = 0
@@ -49,7 +49,7 @@ module T::Types
49
49
  end
50
50
  end
51
51
 
52
- # @override Base
52
+ # overrides Base
53
53
  private def subtype_of_single?(other)
54
54
  case other
55
55
  when FixedArray
@@ -69,7 +69,7 @@ module T::Types
69
69
  # instead of
70
70
  # "Expected [String, Symbol], got Array".
71
71
  #
72
- # @override Base
72
+ # overrides Base
73
73
  def describe_obj(obj)
74
74
  if obj.is_a?(Array)
75
75
  if obj.length == @types.length
@@ -11,12 +11,12 @@ module T::Types
11
11
  @types = types.transform_values {|v| T::Utils.coerce(v)}
12
12
  end
13
13
 
14
- # @override Base
14
+ # overrides Base
15
15
  def name
16
16
  serialize_hash(@types)
17
17
  end
18
18
 
19
- # @override Base
19
+ # overrides Base
20
20
  def recursively_valid?(obj)
21
21
  return false unless obj.is_a?(Hash)
22
22
  return false if @types.any? {|key, type| !type.recursively_valid?(obj[key])}
@@ -24,7 +24,7 @@ module T::Types
24
24
  true
25
25
  end
26
26
 
27
- # @override Base
27
+ # overrides Base
28
28
  def valid?(obj)
29
29
  return false unless obj.is_a?(Hash)
30
30
  return false if @types.any? {|key, type| !type.valid?(obj[key])}
@@ -32,7 +32,7 @@ module T::Types
32
32
  true
33
33
  end
34
34
 
35
- # @override Base
35
+ # overrides Base
36
36
  private def subtype_of_single?(other)
37
37
  case other
38
38
  when FixedHash
@@ -44,11 +44,11 @@ module T::Types
44
44
  end
45
45
 
46
46
  # This gives us better errors, e.g.:
47
- # "Expected {a: String}, got {a: TrueClass}"
47
+ # `Expected {a: String}, got {a: TrueClass}`
48
48
  # instead of
49
- # "Expected {a: String}, got Hash".
49
+ # `Expected {a: String}, got Hash`.
50
50
  #
51
- # @override Base
51
+ # overrides Base
52
52
  def describe_obj(obj)
53
53
  if obj.is_a?(Hash)
54
54
  "type #{serialize_hash(obj.transform_values(&:class))}"
@@ -18,22 +18,22 @@ module T::Types
18
18
  end.uniq
19
19
  end
20
20
 
21
- # @override Base
21
+ # overrides Base
22
22
  def name
23
23
  "T.all(#{@types.map(&:name).sort.join(', ')})"
24
24
  end
25
25
 
26
- # @override Base
26
+ # overrides Base
27
27
  def recursively_valid?(obj)
28
28
  @types.all? {|type| type.recursively_valid?(obj)}
29
29
  end
30
30
 
31
- # @override Base
31
+ # overrides Base
32
32
  def valid?(obj)
33
33
  @types.all? {|type| type.valid?(obj)}
34
34
  end
35
35
 
36
- # @override Base
36
+ # overrides Base
37
37
  private def subtype_of_single?(other)
38
38
  raise "This should never be reached if you're going through `subtype_of?` (and you should be)"
39
39
  end
@@ -7,17 +7,17 @@ module T::Types
7
7
 
8
8
  def initialize; end
9
9
 
10
- # @override Base
10
+ # overrides Base
11
11
  def name
12
12
  "T.noreturn"
13
13
  end
14
14
 
15
- # @override Base
15
+ # overrides Base
16
16
  def valid?(obj)
17
17
  false
18
18
  end
19
19
 
20
- # @override Base
20
+ # overrides Base
21
21
  private def subtype_of_single?(other)
22
22
  true
23
23
  end
@@ -19,7 +19,7 @@ module T::Types
19
19
  @returns = T::Utils.coerce(returns)
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  def name
24
24
  args = []
25
25
  @arg_types.each do |k, v|
@@ -28,12 +28,12 @@ module T::Types
28
28
  "T.proc.params(#{args.join(', ')}).returns(#{returns})"
29
29
  end
30
30
 
31
- # @override Base
31
+ # overrides Base
32
32
  def valid?(obj)
33
33
  obj.is_a?(::Proc)
34
34
  end
35
35
 
36
- # @override Base
36
+ # overrides Base
37
37
  private def subtype_of_single?(other)
38
38
  case other
39
39
  when self.class
@@ -8,17 +8,17 @@ module T::Types
8
8
 
9
9
  def initialize(); end
10
10
 
11
- # @override Base
11
+ # overrides Base
12
12
  def name
13
13
  "T.self_type"
14
14
  end
15
15
 
16
- # @override Base
16
+ # overrides Base
17
17
  def valid?(obj)
18
18
  true
19
19
  end
20
20
 
21
- # @override Base
21
+ # overrides Base
22
22
  private def subtype_of_single?(other)
23
23
  case other
24
24
  when SelfType
@@ -10,7 +10,7 @@ module T::Types
10
10
  @raw_type = raw_type
11
11
  end
12
12
 
13
- # @override Base
13
+ # overrides Base
14
14
  def name
15
15
  # Memoize to mitigate pathological performance with anonymous modules (https://bugs.ruby-lang.org/issues/11119)
16
16
  #
@@ -19,12 +19,12 @@ module T::Types
19
19
  @name ||= @raw_type.name.freeze
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  def valid?(obj)
24
24
  obj.is_a?(@raw_type)
25
25
  end
26
26
 
27
- # @override Base
27
+ # overrides Base
28
28
  private def subtype_of_single?(other)
29
29
  case other
30
30
  when Simple
@@ -10,7 +10,7 @@ module T::Types
10
10
  @val = val
11
11
  end
12
12
 
13
- # @override Base
13
+ # overrides Base
14
14
  def name
15
15
  # Strips the #<...> off, just leaving the ...
16
16
  # Reasoning: the user will have written something like
@@ -20,12 +20,12 @@ module T::Types
20
20
  @val.inspect[2..-2]
21
21
  end
22
22
 
23
- # @override Base
23
+ # overrides Base
24
24
  def valid?(obj)
25
25
  @val == obj
26
26
  end
27
27
 
28
- # @override Base
28
+ # overrides Base
29
29
  private def subtype_of_single?(other)
30
30
  case other
31
31
  when TEnum
@@ -3,7 +3,7 @@
3
3
 
4
4
  module T::Types
5
5
  class TypedArray < TypedEnumerable
6
- # @override Base
6
+ # overrides Base
7
7
  def name
8
8
  "T::Array[#{@type.name}]"
9
9
  end
@@ -12,12 +12,12 @@ module T::Types
12
12
  Array
13
13
  end
14
14
 
15
- # @override Base
15
+ # overrides Base
16
16
  def recursively_valid?(obj)
17
17
  obj.is_a?(Array) && super
18
18
  end
19
19
 
20
- # @override Base
20
+ # overrides Base
21
21
  def valid?(obj)
22
22
  obj.is_a?(Array)
23
23
  end
@@ -16,17 +16,17 @@ module T::Types
16
16
  Enumerable
17
17
  end
18
18
 
19
- # @override Base
19
+ # overrides Base
20
20
  def name
21
21
  "T::Enumerable[#{@type.name}]"
22
22
  end
23
23
 
24
- # @override Base
24
+ # overrides Base
25
25
  def valid?(obj)
26
26
  obj.is_a?(Enumerable)
27
27
  end
28
28
 
29
- # @override Base
29
+ # overrides Base
30
30
  def recursively_valid?(obj)
31
31
  return false unless obj.is_a?(Enumerable)
32
32
  case obj
@@ -74,7 +74,7 @@ module T::Types
74
74
  end
75
75
  end
76
76
 
77
- # @override Base
77
+ # overrides Base
78
78
  private def subtype_of_single?(other)
79
79
  if other.class <= TypedEnumerable &&
80
80
  underlying_class <= other.underlying_class
@@ -90,7 +90,7 @@ module T::Types
90
90
  end
91
91
  end
92
92
 
93
- # @override Base
93
+ # overrides Base
94
94
  def describe_obj(obj)
95
95
  return super unless obj.is_a?(Enumerable)
96
96
  type_from_instance(obj).name
@@ -9,17 +9,17 @@ module T::Types
9
9
  Enumerator
10
10
  end
11
11
 
12
- # @override Base
12
+ # overrides Base
13
13
  def name
14
14
  "T::Enumerator[#{@type.name}]"
15
15
  end
16
16
 
17
- # @override Base
17
+ # overrides Base
18
18
  def recursively_valid?(obj)
19
19
  obj.is_a?(Enumerator) && super
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  def valid?(obj)
24
24
  obj.is_a?(Enumerator)
25
25
  end
@@ -16,17 +16,17 @@ module T::Types
16
16
  @type = T::Utils.coerce([keys, values])
17
17
  end
18
18
 
19
- # @override Base
19
+ # overrides Base
20
20
  def name
21
21
  "T::Hash[#{@keys.name}, #{@values.name}]"
22
22
  end
23
23
 
24
- # @override Base
24
+ # overrides Base
25
25
  def recursively_valid?(obj)
26
26
  obj.is_a?(Hash) && super
27
27
  end
28
28
 
29
- # @override Base
29
+ # overrides Base
30
30
  def valid?(obj)
31
31
  obj.is_a?(Hash)
32
32
  end
@@ -9,17 +9,17 @@ module T::Types
9
9
  Hash
10
10
  end
11
11
 
12
- # @override Base
12
+ # overrides Base
13
13
  def name
14
14
  "T::Range[#{@type.name}]"
15
15
  end
16
16
 
17
- # @override Base
17
+ # overrides Base
18
18
  def recursively_valid?(obj)
19
19
  obj.is_a?(Range) && super
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  def valid?(obj)
24
24
  obj.is_a?(Range)
25
25
  end
@@ -9,17 +9,17 @@ module T::Types
9
9
  Hash
10
10
  end
11
11
 
12
- # @override Base
12
+ # overrides Base
13
13
  def name
14
14
  "T::Set[#{@type.name}]"
15
15
  end
16
16
 
17
- # @override Base
17
+ # overrides Base
18
18
  def recursively_valid?(obj)
19
19
  obj.is_a?(Set) && super
20
20
  end
21
21
 
22
- # @override Base
22
+ # overrides Base
23
23
  def valid?(obj)
24
24
  obj.is_a?(Set)
25
25
  end
@@ -18,7 +18,7 @@ module T::Types
18
18
  end.uniq
19
19
  end
20
20
 
21
- # @override Base
21
+ # overrides Base
22
22
  def name
23
23
  type_shortcuts(@types)
24
24
  end
@@ -42,17 +42,17 @@ module T::Types
42
42
  end
43
43
  end
44
44
 
45
- # @override Base
45
+ # overrides Base
46
46
  def recursively_valid?(obj)
47
47
  @types.any? {|type| type.recursively_valid?(obj)}
48
48
  end
49
49
 
50
- # @override Base
50
+ # overrides Base
51
51
  def valid?(obj)
52
52
  @types.any? {|type| type.valid?(obj)}
53
53
  end
54
54
 
55
- # @override Base
55
+ # overrides Base
56
56
  private def subtype_of_single?(other)
57
57
  raise "This should never be reached if you're going through `subtype_of?` (and you should be)"
58
58
  end
@@ -7,17 +7,17 @@ module T::Types
7
7
 
8
8
  def initialize; end
9
9
 
10
- # @override Base
10
+ # overrides Base
11
11
  def name
12
12
  "T.untyped"
13
13
  end
14
14
 
15
- # @override Base
15
+ # overrides Base
16
16
  def valid?(obj)
17
17
  true
18
18
  end
19
19
 
20
- # @override Base
20
+ # overrides Base
21
21
  private def subtype_of_single?(other)
22
22
  true
23
23
  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.9167
4
+ version: 0.5.9189
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2021-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest