sorbet-runtime 0.5.6155 → 0.5.6187
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/configuration.rb +49 -0
- data/lib/types/props/private/serde_transform.rb +1 -5
- data/lib/types/types/base.rb +3 -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: d5c7fcf3c51fe26b7a1d543c6944fa6b8f42bd5ec0be423214a26d7fabd2278e
|
4
|
+
data.tar.gz: d53f0ca74f3be3686a6816dbc533a82e041b7b2b5e8b99ed28e4ad823ede10f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8517645bbb2654cff3a09024c07b989c9a4894d8edf7dc5c22f283b39610f4b03c50bbc11135dec60ce1e0f3180eaea124d90b0ae716a54e7ad32c5554010f45
|
7
|
+
data.tar.gz: 2cf70f9612a06da7e84c30ab2baaa900affc9f7e04b36835e0a3b7eb2cf11e400a82f60686945118faed8b2c5fd5f86d6f3e7200d1b4fdd8a88153df386e732e
|
data/lib/types/configuration.rb
CHANGED
@@ -42,6 +42,34 @@ module T::Configuration
|
|
42
42
|
T::Private::Methods.set_final_checks_on_hooks(false)
|
43
43
|
end
|
44
44
|
|
45
|
+
@include_value_in_type_errors = true
|
46
|
+
# Whether to include values in TypeError messages.
|
47
|
+
#
|
48
|
+
# Including values is useful for debugging, but can potentially leak
|
49
|
+
# sensitive information to logs.
|
50
|
+
#
|
51
|
+
# @return [T::Boolean]
|
52
|
+
def self.include_value_in_type_errors?
|
53
|
+
@include_value_in_type_errors
|
54
|
+
end
|
55
|
+
|
56
|
+
# Configure if type errors excludes the value of the problematic type.
|
57
|
+
#
|
58
|
+
# The default is to include values in type errors:
|
59
|
+
# TypeError: Expected type Integer, got String with value "foo"
|
60
|
+
#
|
61
|
+
# When values are excluded from type errors:
|
62
|
+
# TypeError: Expected type Integer, got String
|
63
|
+
def self.exclude_value_in_type_errors
|
64
|
+
@include_value_in_type_errors = false
|
65
|
+
end
|
66
|
+
|
67
|
+
# Opposite of exclude_value_in_type_errors.
|
68
|
+
# (Including values in type errors is the default)
|
69
|
+
def self.include_value_in_type_errors
|
70
|
+
@include_value_in_type_errors = true
|
71
|
+
end
|
72
|
+
|
45
73
|
# Configure the default checked level for a sig with no explicit `.checked`
|
46
74
|
# builder. When unset, the default checked level is `:always`.
|
47
75
|
#
|
@@ -363,6 +391,27 @@ module T::Configuration
|
|
363
391
|
@scalar_types || @default_scalar_types
|
364
392
|
end
|
365
393
|
|
394
|
+
# Guard against overrides of `name` or `to_s`
|
395
|
+
MODULE_NAME = Module.instance_method(:name)
|
396
|
+
private_constant :MODULE_NAME
|
397
|
+
|
398
|
+
@default_module_name_mangler = ->(type) {MODULE_NAME.bind(type).call}
|
399
|
+
@module_name_mangler = nil
|
400
|
+
|
401
|
+
def self.module_name_mangler
|
402
|
+
@module_name_mangler || @default_module_name_mangler
|
403
|
+
end
|
404
|
+
|
405
|
+
# Set to override the default behavior for converting types
|
406
|
+
# to names in generated code. Used by the runtime implementation
|
407
|
+
# associated with `--stripe-packages` mode.
|
408
|
+
#
|
409
|
+
# @param [Lambda, Proc, nil] value Proc that converts a type (Class/Module)
|
410
|
+
# to a String (pass nil to reset to default behavior)
|
411
|
+
def self.module_name_mangler=(handler)
|
412
|
+
@module_name_mangler = handler
|
413
|
+
end
|
414
|
+
|
366
415
|
# Temporarily disable ruby warnings while executing the given block. This is
|
367
416
|
# useful when doing something that would normally cause a warning to be
|
368
417
|
# emitted in Ruby verbose mode ($VERBOSE = true).
|
@@ -177,13 +177,9 @@ module T::Props
|
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
-
# Guard against overrides of `name` or `to_s`
|
181
|
-
MODULE_NAME = T.let(Module.instance_method(:name), UnboundMethod)
|
182
|
-
private_constant :MODULE_NAME
|
183
|
-
|
184
180
|
sig {params(type: Module).returns(T.nilable(String)).checked(:never)}
|
185
181
|
private_class_method def self.module_name(type)
|
186
|
-
|
182
|
+
T::Configuration.module_name_mangler.call(type)
|
187
183
|
end
|
188
184
|
end
|
189
185
|
end
|
data/lib/types/types/base.rb
CHANGED
@@ -119,8 +119,10 @@ module T::Types
|
|
119
119
|
# Default inspect behavior of, eg; `#<Object:0x0...>` is ugly; just print the hash instead, which is more concise/readable.
|
120
120
|
if obj.method(:inspect).owner == Kernel
|
121
121
|
"type #{obj.class} with hash #{obj.hash}"
|
122
|
-
|
122
|
+
elsif T::Configuration.include_value_in_type_errors?
|
123
123
|
"type #{obj.class} with value #{T::Utils.string_truncate_middle(obj.inspect, 30, 30)}"
|
124
|
+
else
|
125
|
+
"type #{obj.class}"
|
124
126
|
end
|
125
127
|
rescue StandardError, SystemStackError
|
126
128
|
"type #{obj.class} with unprintable value"
|
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.6187
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|