steep 1.5.0.pre.6 → 1.5.0
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/CHANGELOG.md +18 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/steep/diagnostic/ruby.rb +148 -33
- data/lib/steep/drivers/init.rb +3 -2
- data/lib/steep/project/dsl.rb +0 -21
- data/lib/steep/source.rb +8 -13
- data/lib/steep/type_construction.rb +21 -19
- data/lib/steep/type_inference/logic_type_interpreter.rb +8 -6
- data/lib/steep/version.rb +1 -1
- data/sig/steep/ast/types/factory.rbs +1 -2
- data/sig/steep/diagnostic/ruby.rbs +20 -6
- data/sig/steep/project/dsl.rbs +7 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77aea7baf36285cf4a5b0941e63cc8f5f95d52132d3a5d4933a396a79b949721
|
|
4
|
+
data.tar.gz: 2506370595dde6633abbab74b1e370d435579415a154b4a82b4da3bb1b065627
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f3190f0ca65a931f9c88d99cbd67836478d754439b5630b1b68f89e9fa6d84a84cc8bde32335d4bdb38b3f13aefaeaf93a75b53722a0b6841eab27e9b689ed8
|
|
7
|
+
data.tar.gz: 94576f1eedcb8c46ca8228e84e4100e860c0e3ed2a28dc209afa80abdeeed188118f1589dcb15d0a8edb0cd8c751f611035a15b613d284113c8cbebcce42dc6e
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
## master
|
|
4
4
|
|
|
5
|
+
## 1.5.0 (2023-07-13)
|
|
6
|
+
|
|
7
|
+
### Type checker core
|
|
8
|
+
|
|
9
|
+
* Fix for the case `untyped` is the proc type hint ([#868](https://github.com/soutaro/steep/pull/868))
|
|
10
|
+
* Type case with type variable ([#869](https://github.com/soutaro/steep/pull/869))
|
|
11
|
+
* Filx `nil?` unreachability detection ([#867](https://github.com/soutaro/steep/pull/867))
|
|
12
|
+
|
|
13
|
+
### Commandline tool
|
|
14
|
+
|
|
15
|
+
* Update `#configure_code_diagnostics` type ([#873](https://github.com/soutaro/steep/pull/873))
|
|
16
|
+
* Update diagnostics templates ([#871](https://github.com/soutaro/steep/pull/871))
|
|
17
|
+
* Removed "set" from "libray" in init.rb and README ([#870](https://github.com/soutaro/steep/pull/870))
|
|
18
|
+
|
|
19
|
+
### Language server
|
|
20
|
+
|
|
21
|
+
* Use RBS::Buffer method to calculate position ([#872](https://github.com/soutaro/steep/pull/872))
|
|
22
|
+
|
|
5
23
|
## 1.5.0.pre.6 (2023-07-11)
|
|
6
24
|
|
|
7
25
|
### Type checker core
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -992,20 +992,57 @@ module Steep
|
|
|
992
992
|
def self.default
|
|
993
993
|
@default ||= _ = all_error.merge(
|
|
994
994
|
{
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
995
|
+
ArgumentTypeMismatch => :error,
|
|
996
|
+
BlockBodyTypeMismatch => :hint,
|
|
997
|
+
BlockTypeMismatch => :hint,
|
|
998
|
+
BreakTypeMismatch => :hint,
|
|
999
|
+
DifferentMethodParameterKind => :hint,
|
|
1000
|
+
FallbackAny => :hint,
|
|
1001
|
+
FalseAssertion => :hint,
|
|
1002
|
+
ImplicitBreakValueMismatch => :hint,
|
|
1003
|
+
IncompatibleAnnotation => :hint,
|
|
1004
|
+
IncompatibleArgumentForwarding => :warning,
|
|
1005
|
+
IncompatibleAssignment => :hint,
|
|
1006
|
+
IncompatibleMethodTypeAnnotation => :hint,
|
|
1007
|
+
IncompatibleTypeCase => :hint,
|
|
1008
|
+
InsufficientKeywordArguments => :error,
|
|
1009
|
+
InsufficientPositionalArguments => :error,
|
|
1010
|
+
InsufficientTypeArgument => :hint,
|
|
1011
|
+
MethodArityMismatch => :error,
|
|
1012
|
+
MethodBodyTypeMismatch => :error,
|
|
1013
|
+
MethodDefinitionMissing => nil,
|
|
1014
|
+
MethodParameterMismatch => :error,
|
|
1015
|
+
MethodReturnTypeAnnotationMismatch => :hint,
|
|
1016
|
+
MultipleAssignmentConversionError => :hint,
|
|
1017
|
+
NoMethod => :error,
|
|
1018
|
+
ProcHintIgnored => :hint,
|
|
1019
|
+
ProcTypeExpected => :hint,
|
|
1020
|
+
RBSError => :information,
|
|
1021
|
+
RequiredBlockMissing => :error,
|
|
1022
|
+
ReturnTypeMismatch => :error,
|
|
1023
|
+
SetterBodyTypeMismatch => :information,
|
|
1024
|
+
SetterReturnTypeMismatch => :information,
|
|
1025
|
+
SyntaxError => :hint,
|
|
1026
|
+
TypeArgumentMismatchError => :hint,
|
|
1027
|
+
UnexpectedBlockGiven => :warning,
|
|
1028
|
+
UnexpectedDynamicMethod => :hint,
|
|
1029
|
+
UnexpectedError => :hint,
|
|
1030
|
+
UnexpectedJump => :hint,
|
|
1031
|
+
UnexpectedJumpValue => :hint,
|
|
1032
|
+
UnexpectedKeywordArgument => :error,
|
|
1033
|
+
UnexpectedPositionalArgument => :error,
|
|
1034
|
+
UnexpectedSplat => :hint,
|
|
1035
|
+
UnexpectedSuper => :information,
|
|
1036
|
+
UnexpectedTypeArgument => :hint,
|
|
1037
|
+
UnexpectedYield => :warning,
|
|
999
1038
|
UnknownConstant => :warning,
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
SetterBodyTypeMismatch => nil,
|
|
1008
|
-
SetterReturnTypeMismatch => nil
|
|
1039
|
+
UnknownGlobalVariable => :warning,
|
|
1040
|
+
UnknownInstanceVariable => :information,
|
|
1041
|
+
UnreachableBranch => :hint,
|
|
1042
|
+
UnreachableValueBranch => :hint,
|
|
1043
|
+
UnresolvedOverloading => :error,
|
|
1044
|
+
UnsatisfiableConstraint => :hint,
|
|
1045
|
+
UnsupportedSyntax => :hint,
|
|
1009
1046
|
}
|
|
1010
1047
|
).freeze
|
|
1011
1048
|
end
|
|
@@ -1013,17 +1050,57 @@ module Steep
|
|
|
1013
1050
|
def self.strict
|
|
1014
1051
|
@strict ||= _ = all_error.merge(
|
|
1015
1052
|
{
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1053
|
+
ArgumentTypeMismatch => :error,
|
|
1054
|
+
BlockBodyTypeMismatch => :error,
|
|
1055
|
+
BlockTypeMismatch => :error,
|
|
1056
|
+
BreakTypeMismatch => :error,
|
|
1057
|
+
DifferentMethodParameterKind => :error,
|
|
1058
|
+
FallbackAny => :warning,
|
|
1059
|
+
FalseAssertion => :error,
|
|
1060
|
+
ImplicitBreakValueMismatch => :information,
|
|
1061
|
+
IncompatibleAnnotation => :error,
|
|
1062
|
+
IncompatibleArgumentForwarding => :error,
|
|
1063
|
+
IncompatibleAssignment => :error,
|
|
1064
|
+
IncompatibleMethodTypeAnnotation => :error,
|
|
1065
|
+
IncompatibleTypeCase => :error,
|
|
1066
|
+
InsufficientKeywordArguments => :error,
|
|
1067
|
+
InsufficientPositionalArguments => :error,
|
|
1068
|
+
InsufficientTypeArgument => :error,
|
|
1069
|
+
MethodArityMismatch => :error,
|
|
1070
|
+
MethodBodyTypeMismatch => :error,
|
|
1071
|
+
MethodDefinitionMissing => :hint,
|
|
1072
|
+
MethodParameterMismatch => :error,
|
|
1073
|
+
MethodReturnTypeAnnotationMismatch => :error,
|
|
1074
|
+
MultipleAssignmentConversionError => :error,
|
|
1075
|
+
NoMethod => :error,
|
|
1076
|
+
ProcHintIgnored => :information,
|
|
1077
|
+
ProcTypeExpected => :error,
|
|
1078
|
+
RBSError => :error,
|
|
1079
|
+
RequiredBlockMissing => :error,
|
|
1080
|
+
ReturnTypeMismatch => :error,
|
|
1025
1081
|
SetterBodyTypeMismatch => :error,
|
|
1026
|
-
SetterReturnTypeMismatch => :error
|
|
1082
|
+
SetterReturnTypeMismatch => :error,
|
|
1083
|
+
SyntaxError => :hint,
|
|
1084
|
+
TypeArgumentMismatchError => :error,
|
|
1085
|
+
UnexpectedBlockGiven => :error,
|
|
1086
|
+
UnexpectedDynamicMethod => :information,
|
|
1087
|
+
UnexpectedError => :information,
|
|
1088
|
+
UnexpectedJump => :error,
|
|
1089
|
+
UnexpectedJumpValue => :error,
|
|
1090
|
+
UnexpectedKeywordArgument => :error,
|
|
1091
|
+
UnexpectedPositionalArgument => :error,
|
|
1092
|
+
UnexpectedSplat => :warning,
|
|
1093
|
+
UnexpectedSuper => :error,
|
|
1094
|
+
UnexpectedTypeArgument => :error,
|
|
1095
|
+
UnexpectedYield => :error,
|
|
1096
|
+
UnknownConstant => :error,
|
|
1097
|
+
UnknownGlobalVariable => :error,
|
|
1098
|
+
UnknownInstanceVariable => :error,
|
|
1099
|
+
UnreachableBranch => :information,
|
|
1100
|
+
UnreachableValueBranch => :warning,
|
|
1101
|
+
UnresolvedOverloading => :error,
|
|
1102
|
+
UnsatisfiableConstraint => :error,
|
|
1103
|
+
UnsupportedSyntax => :information,
|
|
1027
1104
|
}
|
|
1028
1105
|
).freeze
|
|
1029
1106
|
end
|
|
@@ -1031,19 +1108,57 @@ module Steep
|
|
|
1031
1108
|
def self.lenient
|
|
1032
1109
|
@lenient ||= _ = all_error.merge(
|
|
1033
1110
|
{
|
|
1034
|
-
|
|
1035
|
-
|
|
1111
|
+
ArgumentTypeMismatch => :information,
|
|
1112
|
+
BlockBodyTypeMismatch => :hint,
|
|
1113
|
+
BlockTypeMismatch => :hint,
|
|
1114
|
+
BreakTypeMismatch => :hint,
|
|
1115
|
+
DifferentMethodParameterKind => nil,
|
|
1036
1116
|
FallbackAny => nil,
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1117
|
+
FalseAssertion => nil,
|
|
1118
|
+
ImplicitBreakValueMismatch => nil,
|
|
1119
|
+
IncompatibleAnnotation => nil,
|
|
1120
|
+
IncompatibleArgumentForwarding => :information,
|
|
1121
|
+
IncompatibleAssignment => :hint,
|
|
1122
|
+
IncompatibleMethodTypeAnnotation => nil,
|
|
1123
|
+
IncompatibleTypeCase => nil,
|
|
1124
|
+
InsufficientKeywordArguments => :information,
|
|
1125
|
+
InsufficientPositionalArguments => :information,
|
|
1126
|
+
InsufficientTypeArgument => nil,
|
|
1127
|
+
MethodArityMismatch => :information,
|
|
1128
|
+
MethodBodyTypeMismatch => :warning,
|
|
1040
1129
|
MethodDefinitionMissing => nil,
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1130
|
+
MethodParameterMismatch => :warning,
|
|
1131
|
+
MethodReturnTypeAnnotationMismatch => nil,
|
|
1132
|
+
MultipleAssignmentConversionError => nil,
|
|
1133
|
+
NoMethod => :information,
|
|
1134
|
+
ProcHintIgnored => nil,
|
|
1135
|
+
ProcTypeExpected => nil,
|
|
1136
|
+
RBSError => :information,
|
|
1137
|
+
RequiredBlockMissing => :hint,
|
|
1138
|
+
ReturnTypeMismatch => :warning,
|
|
1045
1139
|
SetterBodyTypeMismatch => nil,
|
|
1046
|
-
SetterReturnTypeMismatch => nil
|
|
1140
|
+
SetterReturnTypeMismatch => nil,
|
|
1141
|
+
SyntaxError => :hint,
|
|
1142
|
+
TypeArgumentMismatchError => nil,
|
|
1143
|
+
UnexpectedBlockGiven => :hint,
|
|
1144
|
+
UnexpectedDynamicMethod => nil,
|
|
1145
|
+
UnexpectedError => :hint,
|
|
1146
|
+
UnexpectedJump => nil,
|
|
1147
|
+
UnexpectedJumpValue => nil,
|
|
1148
|
+
UnexpectedKeywordArgument => :information,
|
|
1149
|
+
UnexpectedPositionalArgument => :information,
|
|
1150
|
+
UnexpectedSplat => nil,
|
|
1151
|
+
UnexpectedSuper => nil,
|
|
1152
|
+
UnexpectedTypeArgument => nil,
|
|
1153
|
+
UnexpectedYield => :information,
|
|
1154
|
+
UnknownConstant => :hint,
|
|
1155
|
+
UnknownGlobalVariable => :hint,
|
|
1156
|
+
UnknownInstanceVariable => :hint,
|
|
1157
|
+
UnreachableBranch => :hint,
|
|
1158
|
+
UnreachableValueBranch => :hint,
|
|
1159
|
+
UnresolvedOverloading => :information,
|
|
1160
|
+
UnsatisfiableConstraint => :hint,
|
|
1161
|
+
UnsupportedSyntax => :hint,
|
|
1047
1162
|
}
|
|
1048
1163
|
).freeze
|
|
1049
1164
|
end
|
data/lib/steep/drivers/init.rb
CHANGED
|
@@ -18,9 +18,10 @@ module Steep
|
|
|
18
18
|
# check "app/models/**/*.rb" # Glob
|
|
19
19
|
# # ignore "lib/templates/*.rb"
|
|
20
20
|
#
|
|
21
|
-
# # library "pathname"
|
|
21
|
+
# # library "pathname" # Standard libraries
|
|
22
22
|
# # library "strong_json" # Gems
|
|
23
23
|
#
|
|
24
|
+
# # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
|
|
24
25
|
# # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
|
|
25
26
|
# # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
|
|
26
27
|
# # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
|
|
@@ -34,7 +35,7 @@ module Steep
|
|
|
34
35
|
#
|
|
35
36
|
# check "test"
|
|
36
37
|
#
|
|
37
|
-
# # library "pathname"
|
|
38
|
+
# # library "pathname" # Standard libraries
|
|
38
39
|
# end
|
|
39
40
|
EOF
|
|
40
41
|
|
data/lib/steep/project/dsl.rb
CHANGED
|
@@ -143,27 +143,6 @@ module Steep
|
|
|
143
143
|
@repo_paths.push(*paths.map {|s| Pathname(s) })
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
# Configure the code diagnostics printing setup.
|
|
147
|
-
#
|
|
148
|
-
# Yields a hash, and the update the hash in the block.
|
|
149
|
-
#
|
|
150
|
-
# ```rb
|
|
151
|
-
# D = Steep::Diagnostic
|
|
152
|
-
#
|
|
153
|
-
# configure_code_diagnostics do |hash|
|
|
154
|
-
# # Assign one of :error, :warning, :information, :hint or :nil to error classes.
|
|
155
|
-
# hash[D::Ruby::UnexpectedPositionalArgument] = :error
|
|
156
|
-
# end
|
|
157
|
-
# ```
|
|
158
|
-
#
|
|
159
|
-
# Passing a hash is also allowed.
|
|
160
|
-
#
|
|
161
|
-
# ```rb
|
|
162
|
-
# D = Steep::Diagnostic
|
|
163
|
-
#
|
|
164
|
-
# configure_code_diagnostics(D::Ruby.lenient)
|
|
165
|
-
# ```
|
|
166
|
-
#
|
|
167
146
|
def configure_code_diagnostics(hash = nil)
|
|
168
147
|
if hash
|
|
169
148
|
code_diagnostics_config.merge!(hash)
|
data/lib/steep/source.rb
CHANGED
|
@@ -330,13 +330,12 @@ module Steep
|
|
|
330
330
|
def find_heredoc_nodes(line, column, position)
|
|
331
331
|
each_heredoc_node() do |nodes, location|
|
|
332
332
|
node = nodes[0]
|
|
333
|
+
loc = location.heredoc_body #: Parser::Source::Range
|
|
333
334
|
|
|
334
|
-
range =
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if range && (range === position)
|
|
339
|
-
return nodes
|
|
335
|
+
if range = loc.to_range
|
|
336
|
+
if range.begin <= position && position <= range.end
|
|
337
|
+
return nodes
|
|
338
|
+
end
|
|
340
339
|
end
|
|
341
340
|
end
|
|
342
341
|
|
|
@@ -344,12 +343,10 @@ module Steep
|
|
|
344
343
|
end
|
|
345
344
|
|
|
346
345
|
def find_nodes_loc(node, position, parents)
|
|
347
|
-
range = node.location.expression&.
|
|
348
|
-
r.begin_pos..r.end_pos
|
|
349
|
-
end
|
|
346
|
+
range = node.location.expression&.to_range
|
|
350
347
|
|
|
351
348
|
if range
|
|
352
|
-
if range
|
|
349
|
+
if range.begin <= position && position <= range.end
|
|
353
350
|
parents.unshift node
|
|
354
351
|
|
|
355
352
|
Source.each_child_node(node) do |child|
|
|
@@ -366,9 +363,7 @@ module Steep
|
|
|
366
363
|
def find_nodes(line:, column:)
|
|
367
364
|
return [] unless node
|
|
368
365
|
|
|
369
|
-
position = (line
|
|
370
|
-
node.location.expression.source_buffer.source_line(i+1).size + 1
|
|
371
|
-
end + column
|
|
366
|
+
position = buffer.loc_to_pos([line, column])
|
|
372
367
|
|
|
373
368
|
if heredoc_nodes = find_heredoc_nodes(line, column, position)
|
|
374
369
|
Source.each_child_node(heredoc_nodes[0]) do |child|
|
|
@@ -3103,27 +3103,29 @@ module Steep
|
|
|
3103
3103
|
|
|
3104
3104
|
type_hint = deep_expand_alias(type_hint) || type_hint
|
|
3105
3105
|
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3106
|
+
unless type_hint.is_a?(AST::Types::Any)
|
|
3107
|
+
procs = flatten_union(type_hint).select do |type|
|
|
3108
|
+
check_relation(sub_type: type, super_type: AST::Builtin::Proc.instance_type).success? &&
|
|
3109
|
+
!type.is_a?(AST::Types::Any)
|
|
3110
|
+
end
|
|
3110
3111
|
|
|
3111
|
-
|
|
3112
|
+
proc_instances, proc_types = procs.partition {|type| AST::Builtin::Proc.instance_type?(type) }
|
|
3112
3113
|
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3114
|
+
case
|
|
3115
|
+
when !proc_instances.empty? && proc_types.empty?
|
|
3116
|
+
# `::Proc` is given as a hint
|
|
3117
|
+
when proc_types.size == 1
|
|
3118
|
+
# Proc type is given as a hint
|
|
3119
|
+
hint_proc = proc_types[0] #: AST::Types::Proc
|
|
3120
|
+
params_hint = hint_proc.type.params
|
|
3121
|
+
return_hint = hint_proc.type.return_type
|
|
3122
|
+
block_hint = hint_proc.block
|
|
3123
|
+
self_hint = hint_proc.self_type
|
|
3124
|
+
else
|
|
3125
|
+
typing.add_error(
|
|
3126
|
+
Diagnostic::Ruby::ProcHintIgnored.new(hint_type: original_hint, node: node)
|
|
3127
|
+
)
|
|
3128
|
+
end
|
|
3127
3129
|
end
|
|
3128
3130
|
end
|
|
3129
3131
|
|
|
@@ -280,20 +280,22 @@ module Steep
|
|
|
280
280
|
when AST::Types::Logic::ReceiverIsNil
|
|
281
281
|
if receiver && arguments.size.zero?
|
|
282
282
|
receiver_type = typing.type_of(node: receiver)
|
|
283
|
-
|
|
283
|
+
unwrap = factory.unwrap_optional(receiver_type)
|
|
284
|
+
truthy_receiver = AST::Builtin.nil_type
|
|
285
|
+
falsy_receiver = unwrap || receiver_type
|
|
284
286
|
|
|
285
287
|
truthy_env, falsy_env = refine_node_type(
|
|
286
288
|
env: env,
|
|
287
289
|
node: receiver,
|
|
288
|
-
truthy_type:
|
|
289
|
-
falsy_type:
|
|
290
|
+
truthy_type: truthy_receiver,
|
|
291
|
+
falsy_type: falsy_receiver
|
|
290
292
|
)
|
|
291
293
|
|
|
292
294
|
truthy_result = Result.new(type: TRUE, env: truthy_env, unreachable: false)
|
|
293
|
-
truthy_result.unreachable!
|
|
295
|
+
truthy_result.unreachable! if unwrap == receiver_type
|
|
294
296
|
|
|
295
297
|
falsy_result = Result.new(type: FALSE, env: falsy_env, unreachable: false)
|
|
296
|
-
falsy_result.unreachable! unless
|
|
298
|
+
falsy_result.unreachable! unless unwrap
|
|
297
299
|
|
|
298
300
|
[truthy_result, falsy_result]
|
|
299
301
|
end
|
|
@@ -500,7 +502,7 @@ module Steep
|
|
|
500
502
|
type_case_select0(ty, klass)
|
|
501
503
|
end
|
|
502
504
|
|
|
503
|
-
when AST::Types::Any, AST::Types::Top
|
|
505
|
+
when AST::Types::Any, AST::Types::Top, AST::Types::Var
|
|
504
506
|
[
|
|
505
507
|
[instance_type],
|
|
506
508
|
[type]
|
data/lib/steep/version.rb
CHANGED
|
@@ -77,13 +77,12 @@ module Steep
|
|
|
77
77
|
# Returns a type that doesn't have `nil` in the union component
|
|
78
78
|
#
|
|
79
79
|
# * Returns `nil` if given type is `nil`
|
|
80
|
-
# *
|
|
80
|
+
# * Expand (unfold) the type aliases automatically
|
|
81
81
|
#
|
|
82
82
|
# ```ruby
|
|
83
83
|
# unwrap_optional(`String?`) # => `String`
|
|
84
84
|
# unwrap_optional(`String | Integer | false | nil`) # => `String | Integer | false`
|
|
85
85
|
# unwrap_optional(`nil`) # => nil
|
|
86
|
-
# unwrap_optional(`boolish`) # => `boolish`
|
|
87
86
|
# ```
|
|
88
87
|
#
|
|
89
88
|
def unwrap_optional: (Types::t) -> Types::t?
|
|
@@ -623,7 +623,7 @@ module Steep
|
|
|
623
623
|
end
|
|
624
624
|
|
|
625
625
|
# RBS embedded in the Ruby code has validation error
|
|
626
|
-
#
|
|
626
|
+
#
|
|
627
627
|
class RBSError < Base
|
|
628
628
|
attr_reader error: Signature::Base
|
|
629
629
|
|
|
@@ -662,21 +662,35 @@ module Steep
|
|
|
662
662
|
|
|
663
663
|
ALL: Array[singleton(Base)]
|
|
664
664
|
|
|
665
|
-
type template = Hash[singleton(Base), LSPFormatter::severity]
|
|
665
|
+
type template = Hash[singleton(Base), LSPFormatter::severity?]
|
|
666
666
|
|
|
667
667
|
self.@all_error: template?
|
|
668
|
+
self.@default: template?
|
|
669
|
+
self.@strict: template?
|
|
670
|
+
self.@lenient: template?
|
|
671
|
+
self.@silent: template?
|
|
672
|
+
|
|
673
|
+
# This template reports everything as an error
|
|
674
|
+
#
|
|
668
675
|
def self.all_error: () -> template
|
|
669
676
|
|
|
670
|
-
|
|
677
|
+
# This template detects inconsistencies between RBS and Ruby code APIs
|
|
678
|
+
#
|
|
671
679
|
def self.default: () -> template
|
|
672
680
|
|
|
673
|
-
|
|
681
|
+
# This template helps you keeping your codebase (almost) type-safe
|
|
682
|
+
#
|
|
683
|
+
# You can start with this template to review the problems reported on the project,
|
|
684
|
+
# and you can ignore some kind of errors.
|
|
685
|
+
#
|
|
674
686
|
def self.strict: () -> template
|
|
675
687
|
|
|
676
|
-
|
|
688
|
+
# This template detects inconsistent definition in Ruby code with respect to your RBS definition
|
|
689
|
+
#
|
|
677
690
|
def self.lenient: () -> template
|
|
678
691
|
|
|
679
|
-
|
|
692
|
+
# This template reports nothing
|
|
693
|
+
#
|
|
680
694
|
def self.silent: () -> template
|
|
681
695
|
end
|
|
682
696
|
end
|
data/sig/steep/project/dsl.rbs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
use Steep::Diagnostic::Ruby::template
|
|
2
|
+
|
|
1
3
|
module Steep
|
|
2
4
|
class Project
|
|
3
5
|
class DSL
|
|
@@ -71,10 +73,13 @@ module Steep
|
|
|
71
73
|
# D = Steep::Diagnostic
|
|
72
74
|
#
|
|
73
75
|
# configure_code_diagnostics(D::Ruby.lenient)
|
|
76
|
+
# configure_code_diagnostics(D::Ruby.strict) do |config|
|
|
77
|
+
# config[D::Ruby::NoMethod] = nil
|
|
78
|
+
# end
|
|
74
79
|
# ```
|
|
75
80
|
#
|
|
76
|
-
def configure_code_diagnostics: (
|
|
77
|
-
| () { (
|
|
81
|
+
def configure_code_diagnostics: (template hash) ?{ (template) -> void }-> void
|
|
82
|
+
| () { (template) -> void }-> void
|
|
78
83
|
|
|
79
84
|
def collection_config: (Pathname path) -> void
|
|
80
85
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: steep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.0
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Soutaro Matsumoto
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-07-
|
|
11
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: parser
|
|
@@ -782,9 +782,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
782
782
|
version: 2.7.0
|
|
783
783
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
784
784
|
requirements:
|
|
785
|
-
- - "
|
|
785
|
+
- - ">="
|
|
786
786
|
- !ruby/object:Gem::Version
|
|
787
|
-
version:
|
|
787
|
+
version: '0'
|
|
788
788
|
requirements: []
|
|
789
789
|
rubygems_version: 3.4.10
|
|
790
790
|
signing_key:
|