sorbet-runtime 0.5.12152 → 0.5.12167
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 +4 -4
- data/lib/types/_types.rb +1 -1
- data/lib/types/boolean.rb +1 -1
- data/lib/types/configuration.rb +4 -4
- data/lib/types/enum.rb +35 -35
- data/lib/types/non_forcing_constants.rb +1 -1
- data/lib/types/private/methods/_methods.rb +3 -3
- data/lib/types/private/methods/call_validation.rb +2 -2
- data/lib/types/private/methods/signature.rb +8 -8
- data/lib/types/private/methods/signature_validation.rb +1 -1
- data/lib/types/private/mixins/mixins.rb +1 -1
- data/lib/types/private/runtime_levels.rb +1 -1
- data/lib/types/private/sealed.rb +4 -4
- data/lib/types/props/_props.rb +2 -2
- data/lib/types/props/constructor.rb +1 -1
- data/lib/types/props/custom_type.rb +5 -5
- data/lib/types/props/decorator.rb +23 -23
- data/lib/types/props/generated_code_validation.rb +4 -4
- data/lib/types/props/has_lazily_specialized_methods.rb +12 -12
- data/lib/types/props/optional.rb +2 -2
- data/lib/types/props/pretty_printable.rb +3 -3
- data/lib/types/props/private/apply_default.rb +15 -15
- data/lib/types/props/private/deserializer_generator.rb +1 -1
- data/lib/types/props/private/serde_transform.rb +8 -8
- data/lib/types/props/private/serializer_generator.rb +1 -1
- data/lib/types/props/private/setter_factory.rb +4 -4
- data/lib/types/props/serializable.rb +10 -10
- data/lib/types/props/type_validation.rb +5 -5
- data/lib/types/props/utils.rb +1 -1
- data/lib/types/props/weak_constructor.rb +3 -3
- data/lib/types/sig.rb +2 -2
- data/lib/types/struct.rb +2 -2
- data/lib/types/types/base.rb +6 -6
- data/lib/types/types/fixed_array.rb +1 -1
- data/lib/types/types/fixed_hash.rb +6 -6
- data/lib/types/types/intersection.rb +2 -2
- data/lib/types/types/union.rb +7 -7
- metadata +2 -2
@@ -6,7 +6,7 @@ module T::Props::WeakConstructor
|
|
6
6
|
extend T::Sig
|
7
7
|
|
8
8
|
# checked(:never) - O(runtime object construction)
|
9
|
-
sig {params(hash: T::Hash[Symbol, T.untyped]).void.checked(:never)}
|
9
|
+
sig { params(hash: T::Hash[Symbol, T.untyped]).void.checked(:never) }
|
10
10
|
def initialize(hash={})
|
11
11
|
decorator = self.class.decorator
|
12
12
|
|
@@ -28,7 +28,7 @@ module T::Props::WeakConstructor::DecoratorMethods
|
|
28
28
|
# we'll use to check for any unrecognized input.)
|
29
29
|
#
|
30
30
|
# checked(:never) - O(runtime object construction)
|
31
|
-
sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
|
31
|
+
sig { params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never) }
|
32
32
|
def construct_props_without_defaults(instance, hash)
|
33
33
|
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
34
34
|
# and therefore allocates for each entry.
|
@@ -49,7 +49,7 @@ module T::Props::WeakConstructor::DecoratorMethods
|
|
49
49
|
# we'll use to check for any unrecognized input.)
|
50
50
|
#
|
51
51
|
# checked(:never) - O(runtime object construction)
|
52
|
-
sig {params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never)}
|
52
|
+
sig { params(instance: T::Props::WeakConstructor, hash: T::Hash[Symbol, T.untyped]).returns(Integer).checked(:never) }
|
53
53
|
def construct_props_with_defaults(instance, hash)
|
54
54
|
# Use `each_pair` rather than `count` because, as of Ruby 2.6, the latter delegates to Enumerator
|
55
55
|
# and therefore allocates for each entry.
|
data/lib/types/sig.rb
CHANGED
@@ -14,7 +14,7 @@ module T::Sig
|
|
14
14
|
|
15
15
|
# At runtime, does nothing, but statically it is treated exactly the same
|
16
16
|
# as T::Sig#sig. Only use it in cases where you can't use T::Sig#sig.
|
17
|
-
T::Sig::WithoutRuntime.sig {params(arg0: T.nilable(Symbol), blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void}
|
17
|
+
T::Sig::WithoutRuntime.sig { params(arg0: T.nilable(Symbol), blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void }
|
18
18
|
def self.sig(arg0=nil, &blk); end # rubocop:disable Lint/DuplicateMethods
|
19
19
|
|
20
20
|
$VERBOSE = original_verbose
|
@@ -23,7 +23,7 @@ module T::Sig
|
|
23
23
|
# Declares a method with type signatures and/or
|
24
24
|
# abstract/override/... helpers. See the documentation URL on
|
25
25
|
# {T::Helpers}
|
26
|
-
T::Sig::WithoutRuntime.sig {params(arg0: T.nilable(Symbol), blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void}
|
26
|
+
T::Sig::WithoutRuntime.sig { params(arg0: T.nilable(Symbol), blk: T.proc.bind(T::Private::Methods::DeclBuilder).void).void }
|
27
27
|
def sig(arg0=nil, &blk)
|
28
28
|
T::Private::Methods.declare_sig(self, Kernel.caller_locations(1, 1)&.first, arg0, &blk)
|
29
29
|
end
|
data/lib/types/struct.rb
CHANGED
@@ -30,7 +30,7 @@ class T::ImmutableStruct < T::InexactStruct
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Matches the one in WeakConstructor, but freezes the object
|
33
|
-
sig {params(hash: T::Hash[Symbol, T.untyped]).void.checked(:never)}
|
33
|
+
sig { params(hash: T::Hash[Symbol, T.untyped]).void.checked(:never) }
|
34
34
|
def initialize(hash={})
|
35
35
|
super
|
36
36
|
|
@@ -38,7 +38,7 @@ class T::ImmutableStruct < T::InexactStruct
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Matches the signature in Props, but raises since this is an immutable struct and only const is allowed
|
41
|
-
sig {params(name: Symbol, cls: T.untyped, rules: T.untyped).void}
|
41
|
+
sig { params(name: Symbol, cls: T.untyped, rules: T.untyped).void }
|
42
42
|
def self.prop(name, cls, **rules)
|
43
43
|
return super if (cls.is_a?(Hash) && cls[:immutable]) || rules[:immutable]
|
44
44
|
|
data/lib/types/types/base.rb
CHANGED
@@ -83,27 +83,27 @@ module T::Types
|
|
83
83
|
# Note: order of cases here matters!
|
84
84
|
if t1.is_a?(T::Types::Union) # 7, 8, 9
|
85
85
|
# this will be incorrect if/when we have Type members
|
86
|
-
return t1.types.all? {|t1_member| t1_member.subtype_of?(t2)}
|
86
|
+
return t1.types.all? { |t1_member| t1_member.subtype_of?(t2) }
|
87
87
|
end
|
88
88
|
|
89
89
|
if t2.is_a?(T::Types::Intersection) # 2, 5
|
90
90
|
# this will be incorrect if/when we have Type members
|
91
|
-
return t2.types.all? {|t2_member| t1.subtype_of?(t2_member)}
|
91
|
+
return t2.types.all? { |t2_member| t1.subtype_of?(t2_member) }
|
92
92
|
end
|
93
93
|
|
94
94
|
if t2.is_a?(T::Types::Union)
|
95
95
|
if t1.is_a?(T::Types::Intersection) # 6
|
96
96
|
# dropping either of parts eagerly make subtype test be too strict.
|
97
97
|
# we have to try both cases, when we normally try only one
|
98
|
-
return t2.types.any? {|t2_member| t1.subtype_of?(t2_member)} ||
|
99
|
-
t1.types.any? {|t1_member| t1_member.subtype_of?(t2)}
|
98
|
+
return t2.types.any? { |t2_member| t1.subtype_of?(t2_member) } ||
|
99
|
+
t1.types.any? { |t1_member| t1_member.subtype_of?(t2) }
|
100
100
|
end
|
101
|
-
return t2.types.any? {|t2_member| t1.subtype_of?(t2_member)} # 3
|
101
|
+
return t2.types.any? { |t2_member| t1.subtype_of?(t2_member) } # 3
|
102
102
|
end
|
103
103
|
|
104
104
|
if t1.is_a?(T::Types::Intersection) # 4
|
105
105
|
# this will be incorrect if/when we have Type members
|
106
|
-
return t1.types.any? {|t1_member| t1_member.subtype_of?(t2)}
|
106
|
+
return t1.types.any? { |t1_member| t1_member.subtype_of?(t2) }
|
107
107
|
end
|
108
108
|
|
109
109
|
# 1; Start with some special cases
|
@@ -10,7 +10,7 @@ module T::Types
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def types
|
13
|
-
@types ||= @inner_types.transform_values {|v| T::Utils.coerce(v)}
|
13
|
+
@types ||= @inner_types.transform_values { |v| T::Utils.coerce(v) }
|
14
14
|
end
|
15
15
|
|
16
16
|
def build_type
|
@@ -26,16 +26,16 @@ module T::Types
|
|
26
26
|
# overrides Base
|
27
27
|
def recursively_valid?(obj)
|
28
28
|
return false unless obj.is_a?(Hash)
|
29
|
-
return false if types.any? {|key, type| !type.recursively_valid?(obj[key])}
|
30
|
-
return false if obj.any? {|key, _| !types[key]}
|
29
|
+
return false if types.any? { |key, type| !type.recursively_valid?(obj[key]) }
|
30
|
+
return false if obj.any? { |key, _| !types[key] }
|
31
31
|
true
|
32
32
|
end
|
33
33
|
|
34
34
|
# overrides Base
|
35
35
|
def valid?(obj)
|
36
36
|
return false unless obj.is_a?(Hash)
|
37
|
-
return false if types.any? {|key, type| !type.valid?(obj[key])}
|
38
|
-
return false if obj.any? {|key, _| !types[key]}
|
37
|
+
return false if types.any? { |key, type| !type.valid?(obj[key]) }
|
38
|
+
return false if obj.any? { |key, _| !types[key] }
|
39
39
|
true
|
40
40
|
end
|
41
41
|
|
@@ -48,7 +48,7 @@ module T::Types
|
|
48
48
|
when TypedHash
|
49
49
|
# warning: covariant hashes
|
50
50
|
|
51
|
-
key1, key2, *keys_rest = types.keys.map {|key| T::Utils.coerce(key.class)}
|
51
|
+
key1, key2, *keys_rest = types.keys.map { |key| T::Utils.coerce(key.class) }
|
52
52
|
key_type = if !key2.nil?
|
53
53
|
T::Types::Union::Private::Pool.union_of_types(key1, key2, keys_rest)
|
54
54
|
elsif key1.nil?
|
@@ -32,12 +32,12 @@ module T::Types
|
|
32
32
|
|
33
33
|
# overrides Base
|
34
34
|
def recursively_valid?(obj)
|
35
|
-
types.all? {|type| type.recursively_valid?(obj)}
|
35
|
+
types.all? { |type| type.recursively_valid?(obj) }
|
36
36
|
end
|
37
37
|
|
38
38
|
# overrides Base
|
39
39
|
def valid?(obj)
|
40
|
-
types.all? {|type| type.valid?(obj)}
|
40
|
+
types.all? { |type| type.valid?(obj) }
|
41
41
|
end
|
42
42
|
|
43
43
|
# overrides Base
|
data/lib/types/types/union.rb
CHANGED
@@ -44,11 +44,11 @@ module T::Types
|
|
44
44
|
nilable = T::Utils.coerce(NilClass)
|
45
45
|
trueclass = T::Utils.coerce(TrueClass)
|
46
46
|
falseclass = T::Utils.coerce(FalseClass)
|
47
|
-
if types.any? {|t| t == nilable}
|
48
|
-
remaining_types = types.reject {|t| t == nilable}
|
47
|
+
if types.any? { |t| t == nilable }
|
48
|
+
remaining_types = types.reject { |t| t == nilable }
|
49
49
|
"T.nilable(#{type_shortcuts(remaining_types)})"
|
50
|
-
elsif types.any? {|t| t == trueclass} && types.any? {|t| t == falseclass}
|
51
|
-
remaining_types = types.reject {|t| t == trueclass || t == falseclass}
|
50
|
+
elsif types.any? { |t| t == trueclass } && types.any? { |t| t == falseclass }
|
51
|
+
remaining_types = types.reject { |t| t == trueclass || t == falseclass }
|
52
52
|
type_shortcuts([T::Private::Types::StringHolder.new("T::Boolean")] + remaining_types)
|
53
53
|
else
|
54
54
|
names = types.map(&:name).compact.sort
|
@@ -58,12 +58,12 @@ module T::Types
|
|
58
58
|
|
59
59
|
# overrides Base
|
60
60
|
def recursively_valid?(obj)
|
61
|
-
types.any? {|type| type.recursively_valid?(obj)}
|
61
|
+
types.any? { |type| type.recursively_valid?(obj) }
|
62
62
|
end
|
63
63
|
|
64
64
|
# overrides Base
|
65
65
|
def valid?(obj)
|
66
|
-
types.any? {|type| type.valid?(obj)}
|
66
|
+
types.any? { |type| type.valid?(obj) }
|
67
67
|
end
|
68
68
|
|
69
69
|
# overrides Base
|
@@ -72,7 +72,7 @@ module T::Types
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def unwrap_nilable
|
75
|
-
non_nil_types = types.reject {|t| t == T::Utils::Nilable::NIL_TYPE}
|
75
|
+
non_nil_types = types.reject { |t| t == T::Utils::Nilable::NIL_TYPE }
|
76
76
|
return nil if types.length == non_nil_types.length
|
77
77
|
case non_nil_types.length
|
78
78
|
when 0 then nil
|
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.12167
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|