sorbet-runtime 0.6.13308 → 0.6.13320
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/private/runtime_levels.rb +6 -3
- data/lib/types/private/types/type_alias.rb +26 -2
- data/lib/types/props/decorator.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56f2d4a3622bd5e0926326c8870c236f80eb3593122cacdb712b0eaa7374ae2e
|
|
4
|
+
data.tar.gz: 6f14e6231fe4fec57e661a359814a038fd58bec6136eda6890f95676b81e46c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5af775cf558aa90be620bb9f299ba7b6bd1be28cdc6b39945226b66bc70e730db598bc02e215071fc358f597a751ab59311372f4d46293e5d2d36c750b3d890
|
|
7
|
+
data.tar.gz: 391e378e8f5cd33bd4b2e06b8e2453c127fa9fdf0ef9aef2bb38ff057e0c3b1e7a3253d64d53d93358da56369f78ddf320f2db3bf8f49d48c0c7eeb759d54eb4
|
|
@@ -33,9 +33,12 @@ module T::Private::RuntimeLevels
|
|
|
33
33
|
if !@check_tests && @wrapped_tests_with_validation
|
|
34
34
|
all_checked_tests_sigs = T::Private::Methods.all_checked_tests_sigs
|
|
35
35
|
locations = all_checked_tests_sigs.map { |sig| sig.method.source_location&.join(':') }.join("\n- ")
|
|
36
|
-
|
|
37
|
-
"There are already some methods wrapped with
|
|
38
|
-
|
|
36
|
+
msg = "Toggle `:tests`-level runtime type checking earlier. " \
|
|
37
|
+
"There are already some methods or type aliases wrapped with `.checked(:tests)`"
|
|
38
|
+
if !locations.empty?
|
|
39
|
+
msg += ":\n- #{locations}"
|
|
40
|
+
end
|
|
41
|
+
raise msg
|
|
39
42
|
end
|
|
40
43
|
|
|
41
44
|
_toggle_checking_tests(true)
|
|
@@ -7,6 +7,18 @@ module T::Private::Types
|
|
|
7
7
|
|
|
8
8
|
def initialize(callable)
|
|
9
9
|
@callable = callable
|
|
10
|
+
@checked_level = nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def checked(level)
|
|
14
|
+
if !@checked_level.nil?
|
|
15
|
+
raise "You can't call .checked multiple times on a type alias."
|
|
16
|
+
end
|
|
17
|
+
if !T::Private::RuntimeLevels::LEVELS.include?(level)
|
|
18
|
+
raise ArgumentError.new("Invalid `checked` level '#{level}'. Use one of: #{T::Private::RuntimeLevels::LEVELS}.")
|
|
19
|
+
end
|
|
20
|
+
@checked_level = level
|
|
21
|
+
self
|
|
10
22
|
end
|
|
11
23
|
|
|
12
24
|
def build_type
|
|
@@ -17,6 +29,18 @@ module T::Private::Types
|
|
|
17
29
|
@aliased_type ||= T::Utils.coerce(@callable.call)
|
|
18
30
|
end
|
|
19
31
|
|
|
32
|
+
def effective_aliased_type
|
|
33
|
+
@effective_aliased_type ||= begin
|
|
34
|
+
real_type = aliased_type
|
|
35
|
+
level = @checked_level.nil? ? T::Private::RuntimeLevels.default_checked_level : @checked_level
|
|
36
|
+
if level == :always || (level == :tests && T::Private::RuntimeLevels.check_tests?)
|
|
37
|
+
real_type
|
|
38
|
+
else
|
|
39
|
+
T::Types::Anything::Private::INSTANCE
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
20
44
|
# overrides Base
|
|
21
45
|
def name
|
|
22
46
|
aliased_type.name
|
|
@@ -24,12 +48,12 @@ module T::Private::Types
|
|
|
24
48
|
|
|
25
49
|
# overrides Base
|
|
26
50
|
def recursively_valid?(obj)
|
|
27
|
-
|
|
51
|
+
effective_aliased_type.recursively_valid?(obj)
|
|
28
52
|
end
|
|
29
53
|
|
|
30
54
|
# overrides Base
|
|
31
55
|
def valid?(obj)
|
|
32
|
-
|
|
56
|
+
effective_aliased_type.valid?(obj)
|
|
33
57
|
end
|
|
34
58
|
end
|
|
35
59
|
end
|
|
@@ -631,7 +631,7 @@ class T::Props::Decorator
|
|
|
631
631
|
end
|
|
632
632
|
|
|
633
633
|
unless foreign.is_a?(Proc)
|
|
634
|
-
T::Configuration.
|
|
634
|
+
T::Configuration.hard_assert_handler(<<~MESSAGE, storytime: {prop: prop_name, value: foreign})
|
|
635
635
|
Please use a Proc that returns a model class instead of the model class itself as the argument to `foreign`. In other words:
|
|
636
636
|
|
|
637
637
|
instead of `prop :foo, String, foreign: FooModel`
|
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.6.
|
|
4
|
+
version: 0.6.13320
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: benchmark
|