sorbet-runtime 0.5.5753 → 0.5.5777

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: 1546903bc807b281e7c386c68356cc446ed39aaeb018964c6e8a2c73bbbd5329
4
- data.tar.gz: 309bfe9b616d290d09fc3d02f3f41738d7d7c8de75de0ffe383c31028307e32d
3
+ metadata.gz: d8d5b5c3bb114a8d4370f9bbd1ca0ca223e77db301a8fcac69ed2de0a02823b3
4
+ data.tar.gz: 7c82d2815218425649ef0c444ff450b283ad382343c334d00c901204f3759c15
5
5
  SHA512:
6
- metadata.gz: d2a7f88e1c95586f8dd3a0ea905cb7096bc1650e5a4263fdfe3da49d0bb28eb4788352cf39e96f7f5528563f2a009745ba38cee2aebcf70dde60a5eddba34019
7
- data.tar.gz: 5de061d6e4a138d93328f24170d9b9b3edcd542e0a5042eb37a6b478228775b7290712d769c5f32a01c04076a32d115cd0cf56b322c64d1b25505002bc3db7f5
6
+ metadata.gz: a875422610902849042a717b09b1351dd9a3b18f25919cc39ab8745f02712ddea763b1599098c06034eaa19adc58b44da48a614b3d873a71284ddec7d9bed3c7
7
+ data.tar.gz: be347577b634de03f0fdd388496c3e86cf184e8d40f6414b47b9713dd31ec4e53e808a8a716bbdc31cb7f01a2f60611bdfd6f52d88e8b312932a8fa1f2974c5c
@@ -103,7 +103,7 @@ module T
103
103
  end
104
104
  end
105
105
 
106
- # References a type paramater which was previously defined with
106
+ # References a type parameter which was previously defined with
107
107
  # `type_parameters`.
108
108
  #
109
109
  # This is used for generic methods. Example usage:
@@ -260,7 +260,7 @@ module T::Props
260
260
  # Method calls generated by SerdeTransform
261
261
  private_class_method def self.whitelisted_methods_for_deserialize
262
262
  @whitelisted_methods_for_deserialize ||= {
263
- :lvar => %i{dup map transform_values transform_keys each_with_object nil? []=},
263
+ :lvar => %i{dup map transform_values transform_keys each_with_object nil? []= to_f},
264
264
  :const => %i{deserialize from_hash deep_clone_object soft_assert_handler},
265
265
  }
266
266
  end
@@ -19,7 +19,7 @@ module T::Props
19
19
  end
20
20
 
21
21
  NO_TRANSFORM_TYPES = T.let(
22
- [TrueClass, FalseClass, NilClass, Symbol, String, Numeric].freeze,
22
+ [TrueClass, FalseClass, NilClass, Symbol, String].freeze,
23
23
  T::Array[Module],
24
24
  )
25
25
  private_constant :NO_TRANSFORM_TYPES
@@ -65,6 +65,14 @@ module T::Props
65
65
  raw = type.raw_type
66
66
  if NO_TRANSFORM_TYPES.any? {|cls| raw <= cls}
67
67
  nil
68
+ elsif raw <= Float
69
+ case mode
70
+ when Deserialize then "#{varname}.to_f"
71
+ when Serialize then nil
72
+ else T.absurd(mode)
73
+ end
74
+ elsif raw <= Numeric
75
+ nil
68
76
  elsif raw < T::Props::Serializable
69
77
  handle_serializable_subtype(varname, raw, mode)
70
78
  elsif raw.singleton_class < T::Props::CustomType
@@ -96,6 +104,13 @@ module T::Props
96
104
  if type.types.all? {|t| generate(t, mode, varname).nil?}
97
105
  nil
98
106
  else
107
+ # We currently deep_clone_object if the type was T.any(Integer, Float).
108
+ # When we get better support for union types (maybe this specific
109
+ # union type, because it would be a replacement for
110
+ # Chalk::ODM::DeprecatedNumemric), we could opt to special case
111
+ # this union to have no specific serde transform (the only reason
112
+ # why Float has a special case is because round tripping through
113
+ # JSON might normalize Floats to Integers)
99
114
  "T::Props::Utils.deep_clone_object(#{varname})"
100
115
  end
101
116
  end
@@ -50,7 +50,11 @@ module T::Types
50
50
  # Enumerators can be unbounded: see `[:foo, :bar].cycle`
51
51
  return true
52
52
  when Range
53
- @type.valid?(obj.first) && @type.valid?(obj.last)
53
+ # A nil beginning or a nil end does not provide any type information. That is, nil in a range represents
54
+ # boundlessness, it does not express a type. For example `(nil...nil)` is not a T::Range[NilClass], its a range
55
+ # of unknown types (T::Range[T.untyped]).
56
+ # Similarly, `(nil...1)` is not a `T::Range[T.nilable(Integer)]`, it's a boundless range of Integer.
57
+ (obj.begin.nil? || @type.valid?(obj.begin)) && (obj.end.nil? || @type.valid?(obj.end))
54
58
  when Set
55
59
  obj.each do |item|
56
60
  return false unless @type.valid?(item)
@@ -124,7 +128,13 @@ module T::Types
124
128
  inferred_val = type_from_instances(obj.values)
125
129
  T::Hash[inferred_key, inferred_val]
126
130
  when Range
127
- T::Range[type_from_instances([obj.first, obj.last])]
131
+ # We can't get any information from `NilClass` in ranges (since nil is used to represent boundlessness).
132
+ typeable_objects = [obj.begin, obj.end].compact
133
+ if typeable_objects.empty?
134
+ T::Range[T.untyped]
135
+ else
136
+ T::Range[type_from_instances(typeable_objects)]
137
+ end
128
138
  when Enumerator
129
139
  T::Enumerator[type_from_instances(obj)]
130
140
  when Set
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.5753
4
+ version: 0.5.5777
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest