sorbet-runtime 0.5.11361 → 0.5.11367
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 +0 -3
- data/lib/types/configuration.rb +1 -1
- data/lib/types/enum.rb +24 -24
- data/lib/types/private/methods/decl_builder.rb +3 -3
- data/lib/types/private/methods/signature_validation.rb +1 -1
- data/lib/types/private/runtime_levels.rb +0 -3
- metadata +2 -3
- data/lib/types/private/compiler.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881e490bb87977bd916c6d97efc687dbb7e2003fe09df47c9ad1a59d3bee1e55
|
4
|
+
data.tar.gz: 4a44dbb7e0d04d2f76db31ca6e124cf4af3ab675acd825556a8f7ade189afb7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d452546dd877152d77b4a63be90f5c2945f0c4640635d089b4f128c946bef49979083e02af45ddc390e047d70f36e29c016253bd8af3b34ce977ee1bf20010
|
7
|
+
data.tar.gz: 260e78af30a3bb7c6c261535567d0583afac154fe05f3876f8d6ab30f21dc3109417b57462a5bff2a3b18216be24bd82ac1c010e5b26eefe86c87b24e752cf85
|
data/lib/sorbet-runtime.rb
CHANGED
data/lib/types/configuration.rb
CHANGED
@@ -113,7 +113,7 @@ module T::Configuration
|
|
113
113
|
# statically, so that methods don't have to guard themselves from being
|
114
114
|
# called incorrectly by untyped code.
|
115
115
|
#
|
116
|
-
# @param [:never, :
|
116
|
+
# @param [:never, :tests, :always] default_checked_level
|
117
117
|
def self.default_checked_level=(default_checked_level)
|
118
118
|
T::Private::RuntimeLevels.default_checked_level = default_checked_level
|
119
119
|
end
|
data/lib/types/enum.rb
CHANGED
@@ -185,6 +185,30 @@ class T::Enum
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
# NB: Do not call this method. This exists to allow for a safe migration path in places where enum
|
189
|
+
# values are compared directly against string values.
|
190
|
+
#
|
191
|
+
# Ruby's string has a weird quirk where `'my_string' == obj` calls obj.==('my_string') if obj
|
192
|
+
# responds to the `to_str` method. It does not actually call `to_str` however.
|
193
|
+
#
|
194
|
+
# See https://ruby-doc.org/core-2.4.0/String.html#method-i-3D-3D
|
195
|
+
T::Sig::WithoutRuntime.sig {returns(String)}
|
196
|
+
def to_str
|
197
|
+
msg = 'Implicit conversion of Enum instances to strings is not allowed. Call #serialize instead.'
|
198
|
+
if T::Configuration.legacy_t_enum_migration_mode?
|
199
|
+
T::Configuration.soft_assert_handler(
|
200
|
+
msg,
|
201
|
+
storytime: {
|
202
|
+
class: self.class.name,
|
203
|
+
caller_location: Kernel.caller_locations(1..1)&.[](0)&.then {"#{_1.path}:#{_1.lineno}"},
|
204
|
+
},
|
205
|
+
)
|
206
|
+
serialize.to_s
|
207
|
+
else
|
208
|
+
Kernel.raise NoMethodError.new(msg)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
188
212
|
module LegacyMigrationMode
|
189
213
|
include Kernel
|
190
214
|
extend T::Helpers
|
@@ -197,30 +221,6 @@ class T::Enum
|
|
197
221
|
def serialize; end
|
198
222
|
end
|
199
223
|
|
200
|
-
# NB: Do not call this method. This exists to allow for a safe migration path in places where enum
|
201
|
-
# values are compared directly against string values.
|
202
|
-
#
|
203
|
-
# Ruby's string has a weird quirk where `'my_string' == obj` calls obj.==('my_string') if obj
|
204
|
-
# responds to the `to_str` method. It does not actually call `to_str` however.
|
205
|
-
#
|
206
|
-
# See https://ruby-doc.org/core-2.4.0/String.html#method-i-3D-3D
|
207
|
-
T::Sig::WithoutRuntime.sig {returns(String)}
|
208
|
-
def to_str
|
209
|
-
msg = 'Implicit conversion of Enum instances to strings is not allowed. Call #serialize instead.'
|
210
|
-
if T::Configuration.legacy_t_enum_migration_mode?
|
211
|
-
T::Configuration.soft_assert_handler(
|
212
|
-
msg,
|
213
|
-
storytime: {
|
214
|
-
class: self.class.name,
|
215
|
-
caller_location: Kernel.caller_locations(1..1)&.[](0)&.then {"#{_1.path}:#{_1.lineno}"},
|
216
|
-
},
|
217
|
-
)
|
218
|
-
serialize.to_s
|
219
|
-
else
|
220
|
-
Kernel.raise NoMethodError.new(msg)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
224
|
# WithoutRuntime so that comparison_assertion_failed can assume a constant stack depth
|
225
225
|
T::Sig::WithoutRuntime.sig {params(other: BasicObject).returns(T::Boolean)}
|
226
226
|
def ==(other)
|
@@ -101,7 +101,7 @@ module T::Private::Methods
|
|
101
101
|
if !decl.checked.equal?(ARG_NOT_PROVIDED)
|
102
102
|
raise BuilderError.new("You can't call .checked multiple times in a signature.")
|
103
103
|
end
|
104
|
-
if
|
104
|
+
if level == :never && !decl.on_failure.equal?(ARG_NOT_PROVIDED)
|
105
105
|
raise BuilderError.new("You can't use .checked(:#{level}) with .on_failure because .on_failure will have no effect.")
|
106
106
|
end
|
107
107
|
if !T::Private::RuntimeLevels::LEVELS.include?(level)
|
@@ -119,7 +119,7 @@ module T::Private::Methods
|
|
119
119
|
if !decl.on_failure.equal?(ARG_NOT_PROVIDED)
|
120
120
|
raise BuilderError.new("You can't call .on_failure multiple times in a signature.")
|
121
121
|
end
|
122
|
-
if decl.checked == :never
|
122
|
+
if decl.checked == :never
|
123
123
|
raise BuilderError.new("You can't use .on_failure with .checked(:#{decl.checked}) because .on_failure will have no effect.")
|
124
124
|
end
|
125
125
|
|
@@ -222,7 +222,7 @@ module T::Private::Methods
|
|
222
222
|
end
|
223
223
|
if decl.checked.equal?(ARG_NOT_PROVIDED)
|
224
224
|
default_checked_level = T::Private::RuntimeLevels.default_checked_level
|
225
|
-
if
|
225
|
+
if default_checked_level == :never && !decl.on_failure.equal?(ARG_NOT_PROVIDED)
|
226
226
|
raise BuilderError.new("To use .on_failure you must additionally call .checked(:tests) or .checked(:always), otherwise, the .on_failure has no effect.")
|
227
227
|
end
|
228
228
|
decl.checked = default_checked_level
|
@@ -234,7 +234,7 @@ module T::Private::Methods::SignatureValidation
|
|
234
234
|
return if signature.override_allow_incompatible
|
235
235
|
return if super_signature.mode == Modes.untyped
|
236
236
|
return unless [signature, super_signature].all? do |sig|
|
237
|
-
sig.check_level == :always ||
|
237
|
+
sig.check_level == :always || (sig.check_level == :tests && T::Private::RuntimeLevels.check_tests?)
|
238
238
|
end
|
239
239
|
mode_noun = super_signature.mode == Modes.abstract ? 'implementation' : 'override'
|
240
240
|
|
@@ -12,9 +12,6 @@ module T::Private::RuntimeLevels
|
|
12
12
|
# Don't even validate in tests, b/c too expensive,
|
13
13
|
# or b/c we fully trust the static typing
|
14
14
|
:never,
|
15
|
-
# Validate the sig when the file is using the Sorbet Compiler.
|
16
|
-
# Behaves like :never when interpreted.
|
17
|
-
:compiled,
|
18
15
|
].freeze
|
19
16
|
|
20
17
|
@check_tests = false
|
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.11367
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -159,7 +159,6 @@ files:
|
|
159
159
|
- lib/types/private/caller_utils.rb
|
160
160
|
- lib/types/private/casts.rb
|
161
161
|
- lib/types/private/class_utils.rb
|
162
|
-
- lib/types/private/compiler.rb
|
163
162
|
- lib/types/private/decl_state.rb
|
164
163
|
- lib/types/private/final.rb
|
165
164
|
- lib/types/private/methods/_methods.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# typed: true
|
3
|
-
|
4
|
-
module T::Private
|
5
|
-
module Compiler
|
6
|
-
# If this code ever runs, the caller is running interpreted (or the
|
7
|
-
# compiler didn't see the call to `running_compiled?` statically.)
|
8
|
-
#
|
9
|
-
# The Sorbet Compiler replaces calls to this method unconditionally (no
|
10
|
-
# runtime guards) to return `true` when compiling a file.
|
11
|
-
def self.running_compiled?
|
12
|
-
false
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns `nil` because the compiler isn't running.
|
16
|
-
#
|
17
|
-
# The Sorbet Compiler replaces calls to this method unconditionally (no
|
18
|
-
# runtime guards) to return a String showing the Sorbet Compiler's version
|
19
|
-
# string.
|
20
|
-
def self.compiler_version
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|