steep 0.44.0 → 0.47.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/ruby.yml +3 -2
- data/.gitignore +0 -1
- data/CHANGELOG.md +42 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +75 -0
- data/README.md +2 -1
- data/lib/steep/annotation_parser.rb +1 -1
- data/lib/steep/ast/builtin.rb +7 -1
- data/lib/steep/ast/types/factory.rb +19 -25
- data/lib/steep/cli.rb +7 -1
- data/lib/steep/diagnostic/lsp_formatter.rb +59 -6
- data/lib/steep/diagnostic/ruby.rb +188 -60
- data/lib/steep/diagnostic/signature.rb +38 -15
- data/lib/steep/drivers/check.rb +3 -0
- data/lib/steep/drivers/init.rb +10 -3
- data/lib/steep/drivers/utils/driver_helper.rb +15 -0
- data/lib/steep/drivers/validate.rb +1 -1
- data/lib/steep/drivers/watch.rb +3 -0
- data/lib/steep/equatable.rb +21 -0
- data/lib/steep/interface/function.rb +798 -579
- data/lib/steep/project/dsl.rb +135 -36
- data/lib/steep/project/options.rb +13 -53
- data/lib/steep/project/target.rb +22 -8
- data/lib/steep/server/interaction_worker.rb +245 -26
- data/lib/steep/server/master.rb +2 -2
- data/lib/steep/server/type_check_worker.rb +6 -9
- data/lib/steep/services/file_loader.rb +26 -19
- data/lib/steep/services/goto_service.rb +1 -0
- data/lib/steep/services/hover_content.rb +135 -80
- data/lib/steep/source.rb +12 -11
- data/lib/steep/type_construction.rb +435 -502
- data/lib/steep/type_inference/block_params.rb +3 -6
- data/lib/steep/type_inference/method_params.rb +483 -0
- data/lib/steep/type_inference/send_args.rb +599 -128
- data/lib/steep/typing.rb +46 -21
- data/lib/steep/version.rb +1 -1
- data/lib/steep.rb +4 -2
- data/sample/Steepfile +10 -3
- data/smoke/alias/Steepfile +2 -1
- data/smoke/and/Steepfile +2 -1
- data/smoke/array/Steepfile +2 -1
- data/smoke/array/test_expectations.yml +3 -3
- data/smoke/block/Steepfile +2 -2
- data/smoke/block/c.rb +0 -1
- data/smoke/case/Steepfile +2 -1
- data/smoke/class/Steepfile +2 -1
- data/smoke/class/test_expectations.yml +12 -15
- data/smoke/const/Steepfile +2 -1
- data/smoke/diagnostics/Steepfile +2 -1
- data/smoke/diagnostics/different_method_parameter_kind.rb +9 -0
- data/smoke/diagnostics/method_arity_mismatch.rb +2 -2
- data/smoke/diagnostics/method_parameter_mismatch.rb +10 -0
- data/smoke/diagnostics/test_expectations.yml +108 -31
- data/smoke/diagnostics-rbs/Steepfile +1 -1
- data/smoke/diagnostics-rbs/mixin-class-error.rbs +6 -0
- data/smoke/diagnostics-rbs/test_expectations.yml +12 -0
- data/smoke/diagnostics-rbs-duplicated/Steepfile +2 -1
- data/smoke/diagnostics-ruby-unsat/Steepfile +2 -1
- data/smoke/dstr/Steepfile +2 -1
- data/smoke/ensure/Steepfile +2 -1
- data/smoke/ensure/test_expectations.yml +3 -3
- data/smoke/enumerator/Steepfile +2 -1
- data/smoke/enumerator/test_expectations.yml +1 -1
- data/smoke/extension/Steepfile +2 -1
- data/smoke/extension/e.rbs +1 -1
- data/smoke/hash/Steepfile +2 -1
- data/smoke/hello/Steepfile +2 -1
- data/smoke/if/Steepfile +2 -1
- data/smoke/implements/Steepfile +2 -1
- data/smoke/initialize/Steepfile +2 -1
- data/smoke/integer/Steepfile +2 -1
- data/smoke/interface/Steepfile +2 -1
- data/smoke/kwbegin/Steepfile +2 -1
- data/smoke/lambda/Steepfile +2 -1
- data/smoke/literal/Steepfile +2 -1
- data/smoke/literal/test_expectations.yml +2 -2
- data/smoke/map/Steepfile +2 -1
- data/smoke/method/Steepfile +2 -1
- data/smoke/method/test_expectations.yml +11 -10
- data/smoke/module/Steepfile +2 -1
- data/smoke/regexp/Steepfile +2 -1
- data/smoke/regression/Steepfile +2 -1
- data/smoke/rescue/Steepfile +2 -1
- data/smoke/rescue/test_expectations.yml +3 -3
- data/smoke/self/Steepfile +2 -1
- data/smoke/skip/Steepfile +2 -1
- data/smoke/stdout/Steepfile +2 -1
- data/smoke/super/Steepfile +2 -1
- data/smoke/toplevel/Steepfile +2 -1
- data/smoke/toplevel/test_expectations.yml +3 -3
- data/smoke/tsort/Steepfile +4 -5
- data/smoke/tsort/test_expectations.yml +2 -2
- data/smoke/type_case/Steepfile +2 -1
- data/smoke/unexpected/Steepfile +2 -1
- data/smoke/yield/Steepfile +2 -1
- data/steep.gemspec +2 -2
- metadata +16 -10
- data/sig/project.rbi +0 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcd473b07b749d136220c73d4434747c909fc516b5d14332590a5e46abed65f9
|
4
|
+
data.tar.gz: c652c1608f635556d3c6704746c901b97047b5f2fc670ea563f50aa30d198210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a540a74cb3d514500a5d57d7111ce45b16cafde7855aa182d0a6a188edf74d7203b17368cc275aa574aaa16f5a7f265eb0a95c1fa9c0a524e42fb78b67bffdc
|
7
|
+
data.tar.gz: eac07db23cad1f7eeb697d4f27e4548c45174e23d7552e7bd4246494efb25d8a967c10d6f00c112a1b3070b1a86e0131a4e3f0b95af8bf66f65747ba4e57f16b
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,48 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.47.0 (2021-11-30)
|
6
|
+
|
7
|
+
This update contains update for RBS 1.7.
|
8
|
+
|
9
|
+
* RBS 1.7 ([#455](https://github.com/soutaro/steep/pull/455))
|
10
|
+
* Bug fixes related to `SendArgs` ([#444](https://github.com/soutaro/steep/pull/444), [#449](https://github.com/soutaro/steep/pull/449), [#451](https://github.com/soutaro/steep/pull/451))
|
11
|
+
* LSP completion item formatting improvement ([#442](https://github.com/soutaro/steep/pull/442))
|
12
|
+
|
13
|
+
## 0.46.0 (2021-08-30)
|
14
|
+
|
15
|
+
This release updates Steepfile DSL syntax, introducing `stdlib_path` and `configure_code_diagnostics` syntax (methods).
|
16
|
+
|
17
|
+
* `stdlib_path` allows configuring core/stdlib RBS file locations.
|
18
|
+
* `configure_code_diagnostics` allows configuring _severity_ of each type errors.
|
19
|
+
|
20
|
+
See the PRs for the explanation of these methods.
|
21
|
+
You can try `steep init` to generate updated `Steepfile` template.
|
22
|
+
|
23
|
+
* Flexible diagnostics configuration ([\#422](https://github.com/soutaro/steep/pull/422), [\#423](https://github.com/soutaro/steep/pull/423))
|
24
|
+
* Revise Steepfile _path_ DSL ([\#421](https://github.com/soutaro/steep/pull/421))
|
25
|
+
* Avoid to stop process by invalid jobs_count ([\#419](https://github.com/soutaro/steep/pull/419))
|
26
|
+
* Fix `Steep::Typing::UnknownNodeError` when hover method with numblock ([\#415](https://github.com/soutaro/steep/pull/415))
|
27
|
+
|
28
|
+
## 0.45.0 (2021-08-22)
|
29
|
+
|
30
|
+
* Fix error reporting on `RBS::MixinClassError` ([\#411](https://github.com/soutaro/steep/pull/411))
|
31
|
+
* Compact error reporting for method body type mismatch ([\#414](https://github.com/soutaro/steep/pull/414))
|
32
|
+
* Fix NoMethodError with csend/numblock ([\#412](https://github.com/soutaro/steep/pull/412))
|
33
|
+
* LSP completion for RBS files ([\#404](https://github.com/soutaro/steep/pull/404))
|
34
|
+
* Allow break without value from bot methods ([\#398](https://github.com/soutaro/steep/pull/398))
|
35
|
+
* Type check on lvar assignments ([\#390](https://github.com/soutaro/steep/pull/390))
|
36
|
+
* Assign different error code to break without value ([\#387](https://github.com/soutaro/steep/pull/387))
|
37
|
+
* Support Ruby3 Keyword Arguments ([\#386](https://github.com/soutaro/steep/pull/386))
|
38
|
+
* LSP hover for RBS files ([\#385](https://github.com/soutaro/steep/pull/385), [\#397](https://github.com/soutaro/steep/pull/397))
|
39
|
+
* Fix FileLoader to skip files not matching to the given pattern ([\#382](https://github.com/soutaro/steep/pull/382))
|
40
|
+
* Ruby3 support for numbered block parameters and end-less def ([\#381](https://github.com/soutaro/steep/pull/381))
|
41
|
+
|
42
|
+
## 0.44.1 (2021-04-23)
|
43
|
+
|
44
|
+
* Disable goto declaration and goto type declaration (because they are not implemented) ([#377](https://github.com/soutaro/steep/pull/377))
|
45
|
+
* Fix goto from block calls ([#378](https://github.com/soutaro/steep/pull/378))
|
46
|
+
|
5
47
|
## 0.44.0 (2021-04-22)
|
6
48
|
|
7
49
|
* Implement LSP go to definition/implementation ([#371](https://github.com/soutaro/steep/pull/371), [#375](https://github.com/soutaro/steep/pull/375))
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
steep (0.47.0)
|
5
|
+
activesupport (>= 5.1)
|
6
|
+
language_server-protocol (>= 3.15, < 4.0)
|
7
|
+
listen (~> 3.0)
|
8
|
+
parallel (>= 1.0.0)
|
9
|
+
parser (>= 3.0)
|
10
|
+
rainbow (>= 2.2.2, < 4.0)
|
11
|
+
rbs (~> 1.7.0)
|
12
|
+
terminal-table (>= 2, < 4)
|
13
|
+
|
14
|
+
PATH
|
15
|
+
remote: test/gems/with_steep_types
|
16
|
+
specs:
|
17
|
+
with_steep_types (1.0.0)
|
18
|
+
|
19
|
+
PATH
|
20
|
+
remote: test/gems/without_steep_types
|
21
|
+
specs:
|
22
|
+
without_steep_types (1.0.0)
|
23
|
+
|
24
|
+
GEM
|
25
|
+
remote: https://rubygems.org/
|
26
|
+
specs:
|
27
|
+
activesupport (6.1.4.1)
|
28
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
|
+
i18n (>= 1.6, < 2)
|
30
|
+
minitest (>= 5.1)
|
31
|
+
tzinfo (~> 2.0)
|
32
|
+
zeitwerk (~> 2.3)
|
33
|
+
ast (2.4.2)
|
34
|
+
concurrent-ruby (1.1.9)
|
35
|
+
ffi (1.15.4)
|
36
|
+
i18n (1.8.11)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
language_server-protocol (3.16.0.3)
|
39
|
+
listen (3.7.0)
|
40
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
41
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
42
|
+
minitest (5.14.4)
|
43
|
+
minitest-hooks (1.5.0)
|
44
|
+
minitest (> 5.3)
|
45
|
+
parallel (1.21.0)
|
46
|
+
parser (3.0.3.1)
|
47
|
+
ast (~> 2.4.1)
|
48
|
+
rainbow (3.0.0)
|
49
|
+
rake (13.0.6)
|
50
|
+
rb-fsevent (0.11.0)
|
51
|
+
rb-inotify (0.10.1)
|
52
|
+
ffi (~> 1.0)
|
53
|
+
rbs (1.7.1)
|
54
|
+
stackprof (0.2.17)
|
55
|
+
terminal-table (3.0.2)
|
56
|
+
unicode-display_width (>= 1.1.1, < 3)
|
57
|
+
tzinfo (2.0.4)
|
58
|
+
concurrent-ruby (~> 1.0)
|
59
|
+
unicode-display_width (2.1.0)
|
60
|
+
zeitwerk (2.5.1)
|
61
|
+
|
62
|
+
PLATFORMS
|
63
|
+
ruby
|
64
|
+
|
65
|
+
DEPENDENCIES
|
66
|
+
minitest (~> 5.0)
|
67
|
+
minitest-hooks
|
68
|
+
rake
|
69
|
+
stackprof
|
70
|
+
steep!
|
71
|
+
with_steep_types!
|
72
|
+
without_steep_types!
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
2.2.27
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Install via RubyGems.
|
|
8
8
|
|
9
9
|
### Requirements
|
10
10
|
|
11
|
-
Steep requires Ruby 2.6.
|
11
|
+
Steep requires Ruby 2.6 or later.
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
@@ -126,6 +126,7 @@ end
|
|
126
126
|
|
127
127
|
class Phone
|
128
128
|
# @dynamic country, number
|
129
|
+
attr_reader :country, :number
|
129
130
|
|
130
131
|
def initialize(country:, number:)
|
131
132
|
@country = country
|
data/lib/steep/ast/builtin.rb
CHANGED
@@ -10,8 +10,14 @@ module Steep
|
|
10
10
|
@arity = arity
|
11
11
|
end
|
12
12
|
|
13
|
-
def instance_type(*args)
|
13
|
+
def instance_type(*args, fill_untyped: false)
|
14
|
+
if fill_untyped
|
15
|
+
(arity - args.size).times do
|
16
|
+
args << Builtin.any_type
|
17
|
+
end
|
18
|
+
end
|
14
19
|
arity == args.size or raise "Mulformed instance type: name=#{module_name}, args=#{args}"
|
20
|
+
|
15
21
|
Types::Name::Instance.new(name: module_name, args: args)
|
16
22
|
end
|
17
23
|
|
@@ -194,7 +194,7 @@ module Steep
|
|
194
194
|
end
|
195
195
|
|
196
196
|
def params(type)
|
197
|
-
Interface::Function::Params.
|
197
|
+
Interface::Function::Params.build(
|
198
198
|
required: type.required_positionals.map {|param| type(param.type) },
|
199
199
|
optional: type.optional_positionals.map {|param| type(param.type) },
|
200
200
|
rest: type.rest_positionals&.yield_self {|param| type(param.type) },
|
@@ -621,12 +621,7 @@ module Steep
|
|
621
621
|
Interface::MethodType.new(
|
622
622
|
type_params: [],
|
623
623
|
type: Interface::Function.new(
|
624
|
-
params: Interface::Function::Params.
|
625
|
-
optional: [],
|
626
|
-
rest: nil,
|
627
|
-
required_keywords: {},
|
628
|
-
optional_keywords: {},
|
629
|
-
rest_keywords: nil),
|
624
|
+
params: Interface::Function::Params.build(required: [AST::Types::Literal.new(value: index)]),
|
630
625
|
return_type: elem_type,
|
631
626
|
location: nil
|
632
627
|
),
|
@@ -643,12 +638,7 @@ module Steep
|
|
643
638
|
Interface::MethodType.new(
|
644
639
|
type_params: [],
|
645
640
|
type: Interface::Function.new(
|
646
|
-
params: Interface::Function::Params.
|
647
|
-
optional: [],
|
648
|
-
rest: nil,
|
649
|
-
required_keywords: {},
|
650
|
-
optional_keywords: {},
|
651
|
-
rest_keywords: nil),
|
641
|
+
params: Interface::Function::Params.build(required: [AST::Types::Literal.new(value: index), elem_type]),
|
652
642
|
return_type: elem_type,
|
653
643
|
location: nil
|
654
644
|
),
|
@@ -712,12 +702,14 @@ module Steep
|
|
712
702
|
Interface::MethodType.new(
|
713
703
|
type_params: [],
|
714
704
|
type: Interface::Function.new(
|
715
|
-
params: Interface::Function::Params.
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
705
|
+
params: Interface::Function::Params.build(
|
706
|
+
required: [key_type],
|
707
|
+
optional: [],
|
708
|
+
rest: nil,
|
709
|
+
required_keywords: {},
|
710
|
+
optional_keywords: {},
|
711
|
+
rest_keywords: nil
|
712
|
+
),
|
721
713
|
return_type: value_type,
|
722
714
|
location: nil
|
723
715
|
),
|
@@ -735,12 +727,14 @@ module Steep
|
|
735
727
|
Interface::MethodType.new(
|
736
728
|
type_params: [],
|
737
729
|
type: Interface::Function.new(
|
738
|
-
params: Interface::Function::Params.
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
730
|
+
params: Interface::Function::Params.build(
|
731
|
+
required: [key_type, value_type],
|
732
|
+
optional: [],
|
733
|
+
rest: nil,
|
734
|
+
required_keywords: {},
|
735
|
+
optional_keywords: {},
|
736
|
+
rest_keywords: nil
|
737
|
+
),
|
744
738
|
return_type: value_type,
|
745
739
|
location: nil),
|
746
740
|
block: nil,
|
data/lib/steep/cli.rb
CHANGED
@@ -70,7 +70,7 @@ module Steep
|
|
70
70
|
default = physical_processor_count + modifier
|
71
71
|
command.jobs_count = default
|
72
72
|
opts.on("-j N", "--jobs=N", "Specify the number of type check workers (defaults: #{default})") do |count|
|
73
|
-
command.jobs_count = Integer(count)
|
73
|
+
command.jobs_count = Integer(count) if Integer(count) > 0
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -99,6 +99,9 @@ module Steep
|
|
99
99
|
opts.on("--save-expectations[=PATH]", "Save expectations with current type check result to PATH (or steep_expectations.yml)") do |path|
|
100
100
|
check.save_expectations_path = Pathname(path || "steep_expectations.yml")
|
101
101
|
end
|
102
|
+
opts.on("--severity-level=LEVEL", /^error|warning|information|hint$/, "Specify the minimum diagnostic severity to be recognized as an error (defaults: warning): error, warning, information, or hint") do |level|
|
103
|
+
check.severity_level = level.to_sym
|
104
|
+
end
|
102
105
|
handle_jobs_option check, opts
|
103
106
|
handle_logging_options opts
|
104
107
|
end.parse!(argv)
|
@@ -155,6 +158,9 @@ module Steep
|
|
155
158
|
Drivers::Watch.new(stdout: stdout, stderr: stderr).tap do |command|
|
156
159
|
OptionParser.new do |opts|
|
157
160
|
opts.banner = "Usage: steep watch [options] [dirs]"
|
161
|
+
opts.on("--severity-level=LEVEL", /^error|warning|information|hint$/, "Specify the minimum diagnostic severity to be recognized as an error (defaults: warning): error, warning, information, or hint") do |level|
|
162
|
+
command.severity_level = level.to_sym
|
163
|
+
end
|
158
164
|
handle_jobs_option command, opts
|
159
165
|
handle_logging_options opts
|
160
166
|
end.parse!(argv)
|
@@ -3,13 +3,66 @@ module Steep
|
|
3
3
|
class LSPFormatter
|
4
4
|
LSP = LanguageServer::Protocol
|
5
5
|
|
6
|
+
attr_reader :config
|
7
|
+
attr_reader :default_severity
|
8
|
+
|
9
|
+
ERROR = :error
|
10
|
+
WARNING = :warning
|
11
|
+
INFORMATION = :information
|
12
|
+
HINT = :hint
|
13
|
+
|
14
|
+
def initialize(config = {}, default_severity: ERROR)
|
15
|
+
@config = config
|
16
|
+
@default_severity = default_severity
|
17
|
+
|
18
|
+
config.each do |klass, severity|
|
19
|
+
validate_severity(klass, severity)
|
20
|
+
validate_class(klass)
|
21
|
+
end
|
22
|
+
validate_severity(:default, default_severity)
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_class(klass)
|
26
|
+
unless klass < Diagnostic::Ruby::Base
|
27
|
+
raise "Unexpected diagnostics class `#{klass}` given"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def validate_severity(klass, severity)
|
32
|
+
case severity
|
33
|
+
when ERROR, WARNING, INFORMATION, HINT, nil
|
34
|
+
# ok
|
35
|
+
else
|
36
|
+
raise "Unexpected severity `#{severity}` is specified for #{klass}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
6
40
|
def format(diagnostic)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
41
|
+
severity = severity_for(diagnostic)
|
42
|
+
|
43
|
+
if severity
|
44
|
+
LSP::Interface::Diagnostic.new(
|
45
|
+
message: diagnostic.full_message,
|
46
|
+
code: diagnostic.diagnostic_code,
|
47
|
+
severity: severity,
|
48
|
+
range: diagnostic.location.as_lsp_range
|
49
|
+
).to_hash
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def severity_for(diagnostic)
|
54
|
+
case config.fetch(diagnostic.class, default_severity)
|
55
|
+
when ERROR
|
56
|
+
LSP::Constant::DiagnosticSeverity::ERROR
|
57
|
+
when WARNING
|
58
|
+
LSP::Constant::DiagnosticSeverity::WARNING
|
59
|
+
when INFORMATION
|
60
|
+
LSP::Constant::DiagnosticSeverity::INFORMATION
|
61
|
+
when HINT
|
62
|
+
LSP::Constant::DiagnosticSeverity::HINT
|
63
|
+
when nil
|
64
|
+
nil
|
65
|
+
end
|
13
66
|
end
|
14
67
|
end
|
15
68
|
end
|