sorbet-runtime 0.5.5767 → 0.5.5784
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dde5758a8aab389d1a8773af2770b3ff03f512532677f582746a30da3718683
|
4
|
+
data.tar.gz: 0ac2a97c22950676ea62acd69ba91af9e25771253efb90d3924325b4ce3c2c19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6059a424165e70f94911a26b94ebfa5407f32e9a9bf4a5b5a57096ad75d3d51310856c81e64e3531a1338641a70fb7c6758df74b5efda04fd308fa35f0fca94
|
7
|
+
data.tar.gz: fff2cc38311fe7f91d4e0e0fd1993896899b472efcb0f6cefcb69df3fa8adc5cde87698e7dfa72aada9e47e00b26b465962c245587238a631722f591422e6c2f
|
data/lib/types/_types.rb
CHANGED
@@ -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
|
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
|
data/lib/types/types/t_enum.rb
CHANGED
@@ -12,7 +12,12 @@ module T::Types
|
|
12
12
|
|
13
13
|
# @override Base
|
14
14
|
def name
|
15
|
-
|
15
|
+
# Strips the #<...> off, just leaving the ...
|
16
|
+
# Reasoning: the user will have written something like
|
17
|
+
# T.any(MyEnum::A, MyEnum::B)
|
18
|
+
# in the type, so we should print what they wrote in errors, not:
|
19
|
+
# T.any(#<MyEnum::A>, #<MyEnum::B>)
|
20
|
+
@val.inspect[2..-2]
|
16
21
|
end
|
17
22
|
|
18
23
|
# @override Base
|
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.5784
|
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-
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|