steep 1.2.0.pre.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16805860000461131410384bf4faece6263672c4e3378ecfe464e0f710322f61
4
- data.tar.gz: 3c3bd23ed01ae1fc56f4ecb683e5ef1f6dfdba3ff131be88c93bd43f87b621b2
3
+ metadata.gz: 350eb85d965ebe0f830b76a4866e2380fbc03d19bdafb5c683e5cf426fff35f4
4
+ data.tar.gz: 6be02c8f8628ea4a4c3f701fb4066d678a0237c3079245e2738380a41975dff0
5
5
  SHA512:
6
- metadata.gz: 73c14bad856adc3a5bfbd4f10604a6e42ce73fc338e8891a50de91d86e971a42195aff504fb9c1d9eee41ef39bed8ec05d0622a5208403a2e4d219f3f8a3e85d
7
- data.tar.gz: 2c94b001a204c73498532062c14db1c01fb67b0562f18c815be5ca3dd99ceeea44e65ea13f17909dc6d7f3a00a885810ab0ec3d9d58f9a734913c06566712a42
6
+ metadata.gz: 8d18a11bf1ee0e927651727dde99a9db70e99669c91b37e361b0c4cf1dff6d0b4aab914a63480a4db8477fe49694ab4ba74e99aad4b27f6df64e664ec3d53ca2
7
+ data.tar.gz: 0cf526b1068660ffc759b41f1f197bf85b4f1590619bd2198b6f5fb5e770d26a2c617d53d00aa475cdacfd154eab1fcc1de5ff394da4ef804873b29f5fd9794a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.2.1 (2022-10-22)
6
+
7
+ ### Type checker core
8
+
9
+ * Fix type narrowing on case-when ([#662](https://github.com/soutaro/steep/pull/662))
10
+
11
+ ## 1.2.0 (2022-10-08)
12
+
13
+ ### Commandline tool
14
+
15
+ * Refactor `--jobs` and `--steep-command` option handling ([#654](https://github.com/soutaro/steep/pull/654))
16
+
17
+ ### Miscellaneous
18
+
19
+ * Delete debug prints ([#653](https://github.com/soutaro/steep/pull/653))
20
+ * Update RBS to 2.7.0 ([#655](https://github.com/soutaro/steep/pull/655))
21
+
5
22
  ## 1.2.0.pre.1 (2022-10-06)
6
23
 
7
24
  ### Type checker core
@@ -9,8 +26,7 @@
9
26
  * Support type checking block/proc self type binding ([#637](https://github.com/soutaro/steep/pull/637))
10
27
  * Type check multiple assignment on block parameters ([#641](https://github.com/soutaro/steep/pull/641), [#643](https://github.com/soutaro/steep/pull/643))
11
28
  * Make more multiple assignments type check ([#630](https://github.com/soutaro/steep/pull/630))
12
- * Refactor *shape* calculation ([#635](https://github.com/soutaro/steep/pull/635), [#649
13
- ](https://github.com/soutaro/steep/pull/649))
29
+ * Refactor *shape* calculation ([#635](https://github.com/soutaro/steep/pull/635), [#649](https://github.com/soutaro/steep/pull/649))
14
30
  * Report type errors if argument mismatch on yield ([#640](https://github.com/soutaro/steep/pull/640))
15
31
  * Relax caching requirements to cache more results ([#651](https://github.com/soutaro/steep/pull/651))
16
32
 
data/Gemfile.lock CHANGED
@@ -1,15 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- steep (1.2.0.pre.1)
4
+ steep (1.2.1)
5
5
  activesupport (>= 5.1)
6
+ csv (>= 3.0.9)
7
+ fileutils (>= 1.1.0)
8
+ json (>= 2.1.0)
6
9
  language_server-protocol (>= 3.15, < 4.0)
7
10
  listen (~> 3.0)
11
+ logger (>= 1.3.0)
8
12
  parallel (>= 1.0.0)
9
13
  parser (>= 3.1)
10
14
  rainbow (>= 2.2.2, < 4.0)
11
- rbs (>= 2.7.0.pre)
15
+ rbs (>= 2.7.0)
12
16
  securerandom (>= 0.1)
17
+ strscan (>= 1.0.0)
13
18
  terminal-table (>= 2, < 4)
14
19
 
15
20
  GEM
@@ -22,16 +27,20 @@ GEM
22
27
  tzinfo (~> 2.0)
23
28
  ast (2.4.2)
24
29
  concurrent-ruby (1.1.10)
30
+ csv (3.2.5)
25
31
  debase (0.2.5.beta2)
26
32
  debase-ruby_core_source (>= 0.10.12)
27
33
  debase-ruby_core_source (0.10.16)
28
34
  ffi (1.15.5)
35
+ fileutils (1.6.0)
29
36
  i18n (1.12.0)
30
37
  concurrent-ruby (~> 1.0)
38
+ json (2.6.2)
31
39
  language_server-protocol (3.17.0.1)
32
40
  listen (3.7.1)
33
41
  rb-fsevent (~> 0.10, >= 0.10.3)
34
42
  rb-inotify (~> 0.9, >= 0.9.10)
43
+ logger (1.5.1)
35
44
  minitest (5.16.3)
36
45
  minitest-hooks (1.5.0)
37
46
  minitest (> 5.3)
@@ -45,11 +54,12 @@ GEM
45
54
  rb-fsevent (0.11.2)
46
55
  rb-inotify (0.10.1)
47
56
  ffi (~> 1.0)
48
- rbs (2.7.0.pre.3)
57
+ rbs (2.7.0)
49
58
  ruby-debug-ide (0.7.3)
50
59
  rake (>= 0.8.1)
51
60
  securerandom (0.2.0)
52
61
  stackprof (0.2.21)
62
+ strscan (3.0.4)
53
63
  terminal-table (3.0.2)
54
64
  unicode-display_width (>= 1.1.1, < 3)
55
65
  tzinfo (2.0.5)
data/Gemfile.steep CHANGED
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'steep', '~> 1.1.0'
4
- gem "rbs", "~> 2.7.pre"
3
+ gem 'steep', '~> 1.2.0'
4
+ gem "rbs"
data/Gemfile.steep.lock CHANGED
@@ -23,15 +23,17 @@ GEM
23
23
  rb-fsevent (0.11.2)
24
24
  rb-inotify (0.10.1)
25
25
  ffi (~> 1.0)
26
- rbs (2.7.0.pre.2)
27
- steep (1.1.1)
26
+ rbs (2.7.0)
27
+ securerandom (0.2.0)
28
+ steep (1.2.0)
28
29
  activesupport (>= 5.1)
29
30
  language_server-protocol (>= 3.15, < 4.0)
30
31
  listen (~> 3.0)
31
32
  parallel (>= 1.0.0)
32
33
  parser (>= 3.1)
33
34
  rainbow (>= 2.2.2, < 4.0)
34
- rbs (>= 2.3.2)
35
+ rbs (>= 2.7.0)
36
+ securerandom (>= 0.1)
35
37
  terminal-table (>= 2, < 4)
36
38
  terminal-table (3.0.2)
37
39
  unicode-display_width (>= 1.1.1, < 3)
@@ -43,8 +45,8 @@ PLATFORMS
43
45
  arm64-darwin-21
44
46
 
45
47
  DEPENDENCIES
46
- rbs (~> 2.7.pre)
47
- steep (~> 1.1.0)
48
+ rbs
49
+ steep (~> 1.2.0)
48
50
 
49
51
  BUNDLED WITH
50
52
  2.3.15
data/Steepfile CHANGED
@@ -1,28 +1,28 @@
1
+ D = Steep::Diagnostic
2
+
1
3
  target :app do
2
4
  check "lib"
3
5
  signature "sig"
4
6
 
5
7
  collection_config "rbs_collection.steep.yaml"
6
8
 
9
+ configure_code_diagnostics do |hash| # You can setup everything yourself
10
+ hash[D::Ruby::MethodDefinitionMissing] = :hint
11
+ end
12
+
7
13
  signature "../rbs/sig", "../rbs/stdlib/rdoc/0"
8
14
  library(
9
15
  "set",
10
16
  "pathname",
11
- "json",
12
- "logger",
13
17
  "monitor",
14
18
  "tsort",
15
19
  "uri",
16
20
  'yaml',
17
- 'dbm',
18
21
  'pstore',
19
22
  'singleton',
20
23
  'shellwords',
21
- 'fileutils',
22
24
  'find',
23
25
  'digest',
24
- "strscan",
25
- "rubygems",
26
26
  "optparse",
27
27
  "securerandom"
28
28
  )
data/lib/steep/cli.rb CHANGED
@@ -43,7 +43,9 @@ module Steep
43
43
  end
44
44
 
45
45
  def setup_command
46
- @command = argv.shift&.to_sym
46
+ return false unless command = argv.shift&.to_sym
47
+ @command = command
48
+
47
49
  if CLI.available_commands.include?(@command) || @command == :worker || @command == :vendor
48
50
  true
49
51
  else
@@ -74,16 +76,13 @@ module Steep
74
76
  end
75
77
  end
76
78
 
77
- def handle_jobs_option(command, opts, modifier = 0)
78
- default = physical_processor_count + modifier
79
- command.jobs_count = default
80
- opts.on("-j N", "--jobs=N", "Specify the number of type check workers (defaults: #{default})") do |count|
81
- command.jobs_count = Integer(count) if Integer(count) > 0
79
+ def handle_jobs_option(option, opts)
80
+ opts.on("-j N", "--jobs=N", "Specify the number of type check workers (defaults: #{option.default_jobs_count})") do |count|
81
+ option.jobs_count = Integer(count) if Integer(count) > 0
82
82
  end
83
83
 
84
- command.steep_command = "steep"
85
84
  opts.on("--steep-command=COMMAND", "Specify command to exec Steep CLI for worker (defaults: steep)") do |cmd|
86
- command.steep_command = cmd
85
+ option.steep_command = cmd
87
86
  end
88
87
  end
89
88
 
@@ -115,7 +114,7 @@ module Steep
115
114
  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|
116
115
  check.severity_level = level.to_sym
117
116
  end
118
- handle_jobs_option check, opts
117
+ handle_jobs_option check.jobs_option, opts
119
118
  handle_logging_options opts
120
119
  end.parse!(argv)
121
120
 
@@ -138,7 +137,7 @@ module Steep
138
137
  check.stdin_input[Pathname(object[:path])] = object[:content]
139
138
  end
140
139
  end
141
- handle_jobs_option check, opts
140
+ handle_jobs_option check.jobs_option, opts
142
141
  handle_logging_options opts
143
142
  end.parse!(argv)
144
143
 
@@ -153,7 +152,7 @@ module Steep
153
152
 
154
153
  opts.on("--steepfile=PATH") {|path| check.steepfile = Pathname(path) }
155
154
  opts.on("--format=FORMAT", "Specify output format: csv, table") {|format| check.format = format }
156
- handle_jobs_option check, opts
155
+ handle_jobs_option check.jobs_option, opts
157
156
  handle_logging_options opts
158
157
  end.parse!(argv)
159
158
 
@@ -197,7 +196,7 @@ module Steep
197
196
  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|
198
197
  command.severity_level = level.to_sym
199
198
  end
200
- handle_jobs_option command, opts
199
+ handle_jobs_option command.jobs_option, opts
201
200
  handle_logging_options opts
202
201
  end.parse!(argv)
203
202
 
@@ -210,7 +209,7 @@ module Steep
210
209
  Drivers::Langserver.new(stdout: stdout, stderr: stderr, stdin: stdin).tap do |command|
211
210
  OptionParser.new do |opts|
212
211
  opts.on("--steepfile=PATH") {|path| command.steepfile = Pathname(path) }
213
- handle_jobs_option command, opts, -1
212
+ handle_jobs_option command.jobs_option, opts
214
213
  handle_logging_options opts
215
214
  end.parse!(argv)
216
215
  end.run
@@ -9,15 +9,16 @@ module Steep
9
9
  attr_accessor :with_expectations_path
10
10
  attr_accessor :save_expectations_path
11
11
  attr_accessor :severity_level
12
+ attr_reader :jobs_option
12
13
 
13
14
  include Utils::DriverHelper
14
- include Utils::JobsCount
15
15
 
16
16
  def initialize(stdout:, stderr:)
17
17
  @stdout = stdout
18
18
  @stderr = stderr
19
19
  @command_line_patterns = []
20
20
  @severity_level = :warning
21
+ @jobs_option = Utils::JobsOption.new()
21
22
  end
22
23
 
23
24
  def run
@@ -39,8 +40,8 @@ module Steep
39
40
  steepfile: project.steepfile_path,
40
41
  args: command_line_patterns,
41
42
  delay_shutdown: true,
42
- steep_command: steep_command,
43
- count: jobs_count
43
+ steep_command: jobs_option.steep_command_value,
44
+ count: jobs_option.jobs_count_value
44
45
  )
45
46
 
46
47
  master = Server::Master.new(
@@ -8,9 +8,9 @@ module Steep
8
8
  attr_reader :command_line_args
9
9
  attr_accessor :all_ruby, :all_rbs
10
10
  attr_reader :stdin_input
11
+ attr_reader :jobs_option
11
12
 
12
13
  include Utils::DriverHelper
13
- include Utils::JobsCount
14
14
 
15
15
  def initialize(stdout:, stderr:)
16
16
  @stdout = stdout
@@ -20,6 +20,8 @@ module Steep
20
20
  @all_rbs = false
21
21
  @all_ruby = false
22
22
  @stdin_input = {}
23
+
24
+ @jobs_option = Utils::JobsOption.new()
23
25
  end
24
26
 
25
27
  def run
@@ -88,10 +90,13 @@ module Steep
88
90
  files = target_paths + signature_paths
89
91
 
90
92
  count =
91
- if files.size >= jobs_count
92
- jobs_count
93
+ if jobs_option.jobs_count
94
+ jobs_option.jobs_count
93
95
  else
94
- files.size + 2
96
+ [
97
+ files.size + 2,
98
+ jobs_option.default_jobs_count
99
+ ].min || raise
95
100
  end
96
101
 
97
102
  Steep.logger.info { "Starting #{count} workers for #{files.size} files..." }
@@ -100,7 +105,7 @@ module Steep
100
105
  steepfile: project.steepfile_path,
101
106
  args: [],
102
107
  delay_shutdown: true,
103
- steep_command: steep_command,
108
+ steep_command: jobs_option.steep_command_value,
104
109
  count: count
105
110
  )
106
111
 
@@ -4,15 +4,12 @@ module Steep
4
4
  attr_reader :stdout
5
5
  attr_reader :stderr
6
6
  attr_reader :stdin
7
- attr_reader :latest_update_version
8
7
  attr_reader :write_mutex
9
8
  attr_reader :type_check_queue
10
9
  attr_reader :type_check_thread
10
+ attr_reader :jobs_option
11
11
 
12
12
  include Utils::DriverHelper
13
- include Utils::JobsCount
14
-
15
- TypeCheckRequest = Struct.new(:version, keyword_init: true)
16
13
 
17
14
  def initialize(stdout:, stderr:, stdin:)
18
15
  @stdout = stdout
@@ -20,6 +17,7 @@ module Steep
20
17
  @stdin = stdin
21
18
  @write_mutex = Mutex.new
22
19
  @type_check_queue = Queue.new
20
+ @jobs_option = Utils::JobsOption.new(jobs_count_modifier: -1)
23
21
  end
24
22
 
25
23
  def writer
@@ -37,8 +35,8 @@ module Steep
37
35
  def run
38
36
  @project = load_config()
39
37
 
40
- interaction_worker = Server::WorkerProcess.spawn_worker(:interaction, name: "interaction", steepfile: project.steepfile_path, steep_command: steep_command)
41
- typecheck_workers = Server::WorkerProcess.spawn_typecheck_workers(steepfile: project.steepfile_path, args: [], steep_command: steep_command, count: jobs_count)
38
+ interaction_worker = Server::WorkerProcess.spawn_worker(:interaction, name: "interaction", steepfile: project.steepfile_path, steep_command: jobs_option.steep_command_value)
39
+ typecheck_workers = Server::WorkerProcess.spawn_typecheck_workers(steepfile: project.steepfile_path, args: [], steep_command: jobs_option.steep_command_value, count: jobs_option.jobs_count_value)
42
40
 
43
41
  master = Server::Master.new(
44
42
  project: project,
@@ -100,14 +100,15 @@ module Steep
100
100
  attr_reader :stderr
101
101
  attr_reader :command_line_patterns
102
102
  attr_accessor :format
103
+ attr_reader :jobs_option
103
104
 
104
105
  include Utils::DriverHelper
105
- include Utils::JobsCount
106
106
 
107
107
  def initialize(stdout:, stderr:)
108
108
  @stdout = stdout
109
109
  @stderr = stderr
110
110
  @command_line_patterns = []
111
+ @jobs_option = Utils::JobsOption.new()
111
112
  end
112
113
 
113
114
  def run
@@ -129,8 +130,8 @@ module Steep
129
130
  steepfile: project.steepfile_path,
130
131
  delay_shutdown: true,
131
132
  args: command_line_patterns,
132
- steep_command: steep_command,
133
- count: jobs_count
133
+ steep_command: jobs_option.steep_command_value,
134
+ count: jobs_option.jobs_count_value
134
135
  )
135
136
 
136
137
  master = Server::Master.new(
@@ -0,0 +1,27 @@
1
+ module Steep
2
+ module Drivers
3
+ module Utils
4
+ class JobsOption
5
+ attr_accessor :jobs_count, :steep_command, :jobs_count_modifier
6
+
7
+ include Parallel::ProcessorCount
8
+
9
+ def initialize(jobs_count_modifier: 0)
10
+ @jobs_count_modifier = jobs_count_modifier
11
+ end
12
+
13
+ def default_jobs_count
14
+ physical_processor_count + jobs_count_modifier
15
+ end
16
+
17
+ def jobs_count_value
18
+ jobs_count || default_jobs_count
19
+ end
20
+
21
+ def steep_command_value
22
+ steep_command || "steep"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -6,9 +6,9 @@ module Steep
6
6
  attr_reader :stderr
7
7
  attr_reader :queue
8
8
  attr_accessor :severity_level
9
+ attr_reader :jobs_option
9
10
 
10
11
  include Utils::DriverHelper
11
- include Utils::JobsCount
12
12
 
13
13
  LSP = LanguageServer::Protocol
14
14
 
@@ -18,6 +18,7 @@ module Steep
18
18
  @stderr = stderr
19
19
  @queue = Thread::Queue.new
20
20
  @severity_level = :warning
21
+ @jobs_option = Utils::JobsOption.new()
21
22
  end
22
23
 
23
24
  def watching?(changed_path, files:, dirs:)
@@ -41,7 +42,7 @@ module Steep
41
42
  server_reader = LanguageServer::Protocol::Transport::Io::Reader.new(server_read)
42
43
  server_writer = LanguageServer::Protocol::Transport::Io::Writer.new(server_write)
43
44
 
44
- typecheck_workers = Server::WorkerProcess.spawn_typecheck_workers(steepfile: project.steepfile_path, args: dirs.map(&:to_s), steep_command: steep_command, count: jobs_count)
45
+ typecheck_workers = Server::WorkerProcess.spawn_typecheck_workers(steepfile: project.steepfile_path, args: dirs.map(&:to_s), steep_command: jobs_option.steep_command_value, count: jobs_option.jobs_count_value)
45
46
 
46
47
  master = Server::Master.new(
47
48
  project: project,
@@ -51,7 +52,7 @@ module Steep
51
52
  typecheck_workers: typecheck_workers
52
53
  )
53
54
  master.typecheck_automatically = false
54
- master.commandline_args.push(*dirs)
55
+ master.commandline_args.push(*dirs.map(&:to_s))
55
56
 
56
57
  main_thread = Thread.start do
57
58
  master.start()
@@ -99,6 +100,7 @@ module Steep
99
100
  end
100
101
 
101
102
  removed.each do |path|
103
+ p = Pathname(path)
102
104
  if watching?(p, files: file_paths, dirs: dir_paths)
103
105
  client_writer.write(
104
106
  method: "textDocument/didChange",
@@ -112,7 +114,7 @@ module Steep
112
114
  end
113
115
 
114
116
  client_writer.write(method: "$/typecheck", params: { guid: nil })
115
-
117
+
116
118
  stdout.puts Rainbow("done!").bold
117
119
  end.tap(&:start)
118
120
 
@@ -124,8 +126,7 @@ module Steep
124
126
  client_reader.read do |response|
125
127
  case response[:method]
126
128
  when "textDocument/publishDiagnostics"
127
- uri = URI.parse(response[:params][:uri])
128
- path = project.relative_path(Pathname(uri.path))
129
+ path = PathHelper.to_pathname(response[:params][:uri]) or break
129
130
  buffer = RBS::Buffer.new(content: path.read, name: path)
130
131
  printer = DiagnosticPrinter.new(stdout: stdout, buffer: buffer)
131
132
 
data/lib/steep/source.rb CHANGED
@@ -73,8 +73,6 @@ module Steep
73
73
 
74
74
  if node
75
75
  construct_mapping(node: node, annotations: annotations, mapping: mapping)
76
- else
77
- Steep.logger.fatal { "#{path} is empty source code" }
78
76
  end
79
77
 
80
78
  annotations.each do |annot|
@@ -194,7 +194,6 @@ module Steep
194
194
  fvs = relation.sub_type.free_variables + relation.super_type.free_variables
195
195
  cached = cache[relation, @self_type, @instance_type, @class_type, bounds]
196
196
  if cached && fvs.none? {|var| constraints.unknown?(var) }
197
- Steep.logger.fatal { { cached: relation.to_s }.inspect }
198
197
  cached
199
198
  else
200
199
  if assumptions.member?(relation)
@@ -373,17 +373,41 @@ module Steep
373
373
  ]
374
374
 
375
375
  else
376
+ # There are four possible relations between `type` and `instance_type`
377
+ #
378
+ # ```ruby
379
+ # case object # object: T
380
+ # when K # K: singleton(K)
381
+ # when ...
382
+ # end
383
+ # ````
384
+ #
385
+ # 1. T <: K && K <: T (T == K, T = Integer, K = Numeric)
386
+ # 2. T <: K (example: T = Integer, K = Numeric)
387
+ # 3. K <: T (example: T = Numeric, K = Integer)
388
+ # 4. none of the above (example: T = String, K = Integer)
389
+
376
390
  relation = Subtyping::Relation.new(sub_type: type, super_type: instance_type)
377
391
  if subtyping.check(relation, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.new, instance_type: AST::Types::Instance.new, class_type: AST::Types::Class.new).success?
392
+ # 1 or 2. Satisfies the condition, no narrowing because `type` is already more specific than/equals to `instance_type`
378
393
  [
379
394
  [type],
380
395
  []
381
396
  ]
382
397
  else
383
- [
384
- [],
385
- [type]
386
- ]
398
+ if subtyping.check(relation.flip, constraints: Subtyping::Constraints.empty, self_type: AST::Types::Self.new, instance_type: AST::Types::Instance.new, class_type: AST::Types::Class.new).success?
399
+ # 3. Satisfied the condition, narrows to `instance_type`, but cannot remove it from *falsy* list
400
+ [
401
+ [instance_type],
402
+ [type]
403
+ ]
404
+ else
405
+ # 4
406
+ [
407
+ [],
408
+ [type]
409
+ ]
410
+ end
387
411
  end
388
412
  end
389
413
  end
data/lib/steep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steep
2
- VERSION = "1.2.0.pre.1"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/steep.rb CHANGED
@@ -125,7 +125,7 @@ require "steep/project/dsl"
125
125
 
126
126
  require "steep/expectations"
127
127
  require "steep/drivers/utils/driver_helper"
128
- require "steep/drivers/utils/jobs_count"
128
+ require "steep/drivers/utils/jobs_option"
129
129
  require "steep/drivers/check"
130
130
  require "steep/drivers/checkfile"
131
131
  require "steep/drivers/stats"
@@ -10,12 +10,16 @@ gems:
10
10
  version: '0'
11
11
  source:
12
12
  type: stdlib
13
+ - name: dbm
14
+ version: '0'
15
+ source:
16
+ type: stdlib
13
17
  - name: activesupport
14
18
  version: '6.0'
15
19
  source:
16
20
  type: git
17
21
  name: ruby/gem_rbs_collection
18
- revision: dc7059ea0cdf67f486ca9cea2b01d53f04724652
22
+ revision: 84a7431af1db405ef827bfdd171a37a1416f6099
19
23
  remote: https://github.com/ruby/gem_rbs_collection.git
20
24
  repo_dir: gems
21
25
  - name: ast
@@ -23,25 +27,41 @@ gems:
23
27
  source:
24
28
  type: git
25
29
  name: ruby/gem_rbs_collection
26
- revision: dc7059ea0cdf67f486ca9cea2b01d53f04724652
30
+ revision: 84a7431af1db405ef827bfdd171a37a1416f6099
27
31
  remote: https://github.com/ruby/gem_rbs_collection.git
28
32
  repo_dir: gems
33
+ - name: csv
34
+ version: '0'
35
+ source:
36
+ type: stdlib
37
+ - name: fileutils
38
+ version: '0'
39
+ source:
40
+ type: stdlib
29
41
  - name: i18n
30
42
  version: '1.10'
31
43
  source:
32
44
  type: git
33
45
  name: ruby/gem_rbs_collection
34
- revision: dc7059ea0cdf67f486ca9cea2b01d53f04724652
46
+ revision: 84a7431af1db405ef827bfdd171a37a1416f6099
35
47
  remote: https://github.com/ruby/gem_rbs_collection.git
36
48
  repo_dir: gems
49
+ - name: json
50
+ version: '0'
51
+ source:
52
+ type: stdlib
37
53
  - name: listen
38
54
  version: '3.2'
39
55
  source:
40
56
  type: git
41
57
  name: ruby/gem_rbs_collection
42
- revision: dc7059ea0cdf67f486ca9cea2b01d53f04724652
58
+ revision: 84a7431af1db405ef827bfdd171a37a1416f6099
43
59
  remote: https://github.com/ruby/gem_rbs_collection.git
44
60
  repo_dir: gems
61
+ - name: logger
62
+ version: '0'
63
+ source:
64
+ type: stdlib
45
65
  - name: minitest
46
66
  version: '0'
47
67
  source:
@@ -51,7 +71,7 @@ gems:
51
71
  source:
52
72
  type: git
53
73
  name: ruby/gem_rbs_collection
54
- revision: dc7059ea0cdf67f486ca9cea2b01d53f04724652
74
+ revision: 84a7431af1db405ef827bfdd171a37a1416f6099
55
75
  remote: https://github.com/ruby/gem_rbs_collection.git
56
76
  repo_dir: gems
57
77
  - name: rainbow
@@ -59,26 +79,26 @@ gems:
59
79
  source:
60
80
  type: git
61
81
  name: ruby/gem_rbs_collection
62
- revision: dc7059ea0cdf67f486ca9cea2b01d53f04724652
82
+ revision: 84a7431af1db405ef827bfdd171a37a1416f6099
63
83
  remote: https://github.com/ruby/gem_rbs_collection.git
64
84
  repo_dir: gems
65
85
  - name: securerandom
66
86
  version: '0'
67
87
  source:
68
88
  type: stdlib
69
- - name: monitor
89
+ - name: strscan
70
90
  version: '0'
71
91
  source:
72
92
  type: stdlib
73
- - name: date
93
+ - name: monitor
74
94
  version: '0'
75
95
  source:
76
96
  type: stdlib
77
- - name: singleton
97
+ - name: date
78
98
  version: '0'
79
99
  source:
80
100
  type: stdlib
81
- - name: logger
101
+ - name: singleton
82
102
  version: '0'
83
103
  source:
84
104
  type: stdlib
@@ -94,3 +114,7 @@ gems:
94
114
  version: '0'
95
115
  source:
96
116
  type: stdlib
117
+ - name: forwardable
118
+ version: '0'
119
+ source:
120
+ type: stdlib
@@ -18,3 +18,4 @@ gems:
18
18
  ignore: true
19
19
  - name: with_steep_types
20
20
  ignore: true
21
+ - name: dbm
@@ -0,0 +1,5 @@
1
+ module Parallel
2
+ module ProcessorCount
3
+ def physical_processor_count: () -> Integer
4
+ end
5
+ end
data/sig/steep/cli.rbs ADDED
@@ -0,0 +1,55 @@
1
+ module Steep
2
+ class CLI
3
+ attr_reader argv: Array[String]
4
+
5
+ attr_reader stdout: IO
6
+
7
+ attr_reader stdin: IO
8
+
9
+ attr_reader stderr: IO
10
+
11
+ attr_reader command: Symbol
12
+
13
+ include Parallel::ProcessorCount
14
+
15
+ def initialize: (stdout: IO, stdin: IO, stderr: IO, argv: Array[String]) -> void
16
+
17
+ def self.available_commands: () -> ::Array[Symbol]
18
+
19
+ def process_global_options: () -> bool
20
+
21
+ def setup_command: () -> bool
22
+
23
+ def run: () -> Integer
24
+
25
+ def handle_logging_options: (OptionParser opts) -> void
26
+
27
+ def handle_jobs_option: (Drivers::Utils::JobsOption jobs_option, OptionParser opts) -> void
28
+
29
+ def process_init: () -> Integer
30
+
31
+ def process_check: () -> Integer
32
+
33
+ def process_checkfile: () -> Integer
34
+
35
+ def process_stats: () -> Integer
36
+
37
+ def process_validate: () -> Integer
38
+
39
+ def process_annotations: () -> Integer
40
+
41
+ def process_project: () -> Integer
42
+
43
+ def process_watch: () -> Integer
44
+
45
+ def process_langserver: () -> Integer
46
+
47
+ def process_vendor: () -> Integer
48
+
49
+ def process_binstub: () -> Integer
50
+
51
+ def process_version: () -> Integer
52
+
53
+ def process_worker: () -> Integer
54
+ end
55
+ end
@@ -15,9 +15,9 @@ module Steep
15
15
 
16
16
  attr_accessor severity_level: untyped
17
17
 
18
- include Utils::DriverHelper
18
+ attr_reader jobs_option: Utils::JobsOption
19
19
 
20
- include Utils::JobsCount
20
+ include Utils::DriverHelper
21
21
 
22
22
  def initialize: (stdout: untyped, stderr: untyped) -> void
23
23
 
@@ -10,7 +10,6 @@ module Steep
10
10
  attr_reader command_line_args: Array[String]
11
11
 
12
12
  include Utils::DriverHelper
13
- include Utils::JobsCount
14
13
 
15
14
  attr_accessor all_rbs: bool
16
15
 
@@ -18,6 +17,8 @@ module Steep
18
17
 
19
18
  attr_reader stdin_input: Hash[Pathname, String]
20
19
 
20
+ attr_reader jobs_option: Utils::JobsOption
21
+
21
22
  def initialize: (stdout: IO, stderr: IO) -> void
22
23
 
23
24
  def run: () -> Integer
@@ -1,35 +1,36 @@
1
1
  module Steep
2
2
  module Drivers
3
3
  class Langserver
4
- attr_reader stdout: untyped
4
+ attr_reader stdout: IO
5
5
 
6
- attr_reader stderr: untyped
6
+ attr_reader stderr: IO
7
7
 
8
- attr_reader stdin: untyped
8
+ attr_reader stdin: IO
9
9
 
10
- attr_reader latest_update_version: untyped
10
+ attr_reader write_mutex: Thread::Mutex
11
11
 
12
- attr_reader write_mutex: untyped
12
+ attr_reader type_check_queue: Thread::Queue
13
13
 
14
- attr_reader type_check_queue: untyped
14
+ attr_reader type_check_thread: Thread
15
15
 
16
- attr_reader type_check_thread: untyped
16
+ attr_reader jobs_option: Utils::JobsOption
17
17
 
18
18
  include Utils::DriverHelper
19
19
 
20
- include Utils::JobsCount
20
+ def initialize: (stdout: untyped, stderr: untyped, stdin: untyped) -> void
21
21
 
22
- TypeCheckRequest: untyped
22
+ @writer: LanguageServer::Protocol::Transport::Io::Writer?
23
23
 
24
- def initialize: (stdout: untyped, stderr: untyped, stdin: untyped) -> void
24
+ def writer: () -> LanguageServer::Protocol::Transport::Io::Writer
25
25
 
26
- def writer: () -> untyped
26
+ @reader: LanguageServer::Protocol::Transport::Io::Reader?
27
27
 
28
- def reader: () -> untyped
28
+ def reader: () -> LanguageServer::Protocol::Transport::Io::Reader
29
29
 
30
- def project: () -> untyped
30
+ @project: Project
31
+ def project: () -> Project
31
32
 
32
- def run: () -> 0
33
+ def run: () -> Integer
33
34
  end
34
35
  end
35
36
  end
@@ -1,35 +1,45 @@
1
1
  module Steep
2
2
  module Drivers
3
3
  class Stats
4
+ type file_stats = {
5
+ type: String,
6
+ target: String,
7
+ path: String,
8
+ type: String,
9
+ typed_calls: Integer,
10
+ untyped_calls: Integer,
11
+ total_calls: Integer
12
+ }
13
+
4
14
  class CSVPrinter
5
- attr_reader io: untyped
15
+ attr_reader io: IO
6
16
 
7
- def initialize: (io: untyped) -> void
17
+ def initialize: (io: IO) -> void
8
18
 
9
- def print: (untyped stats_result) -> untyped
19
+ def print: (Array[file_stats] stats_result) -> void
10
20
  end
11
21
 
12
22
  class TablePrinter
13
- attr_reader io: untyped
23
+ attr_reader io: IO
14
24
 
15
- def initialize: (io: untyped) -> void
25
+ def initialize: (io: IO) -> void
16
26
 
17
- def print: (untyped stats_result) -> untyped
27
+ def print: (Array[file_stats] stats_result) -> void
18
28
  end
19
29
 
20
- attr_reader stdout: untyped
30
+ attr_reader stdout: IO
21
31
 
22
- attr_reader stderr: untyped
32
+ attr_reader stderr: IO
23
33
 
24
- attr_reader command_line_patterns: untyped
34
+ attr_reader command_line_patterns: Array[String]
25
35
 
26
- attr_accessor format: untyped
36
+ attr_accessor format: "csv" | "table" | nil
27
37
 
28
- include Utils::DriverHelper
38
+ attr_reader jobs_option: Utils::JobsOption
29
39
 
30
- include Utils::JobsCount
40
+ include Utils::DriverHelper
31
41
 
32
- def initialize: (stdout: untyped, stderr: untyped) -> void
42
+ def initialize: (stdout: IO, stderr: IO) -> void
33
43
 
34
44
  def run: () -> 0
35
45
  end
@@ -0,0 +1,23 @@
1
+ module Steep
2
+ module Drivers
3
+ module Utils
4
+ class JobsOption
5
+ attr_accessor jobs_count: Integer?
6
+
7
+ attr_accessor steep_command: String?
8
+
9
+ attr_reader jobs_count_modifier: Integer
10
+
11
+ include Parallel::ProcessorCount
12
+
13
+ def initialize: (?jobs_count_modifier: Integer) -> void
14
+
15
+ def default_jobs_count: () -> Integer
16
+
17
+ def jobs_count_value: () -> Integer
18
+
19
+ def steep_command_value: () -> String
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,27 +1,27 @@
1
1
  module Steep
2
2
  module Drivers
3
3
  class Watch
4
- attr_reader dirs: untyped
4
+ attr_reader dirs: Array[Pathname]
5
5
 
6
- attr_reader stdout: untyped
6
+ attr_reader stdout: IO
7
7
 
8
- attr_reader stderr: untyped
8
+ attr_reader stderr: IO
9
9
 
10
- attr_reader queue: untyped
10
+ attr_reader queue: Thread::Queue
11
11
 
12
- attr_accessor severity_level: untyped
12
+ attr_accessor severity_level: Symbol
13
13
 
14
- include Utils::DriverHelper
14
+ attr_reader jobs_option: Utils::JobsOption
15
15
 
16
- include Utils::JobsCount
16
+ include Utils::DriverHelper
17
17
 
18
- LSP: untyped
18
+ LSP: singleton(LanguageServer::Protocol)
19
19
 
20
- def initialize: (stdout: untyped, stderr: untyped) -> void
20
+ def initialize: (stdout: IO, stderr: IO) -> void
21
21
 
22
- def watching?: (untyped changed_path, files: untyped, dirs: untyped) -> untyped
22
+ def watching?: (Pathname changed_path, files: Set[Pathname], dirs: Set[Pathname]) -> bool
23
23
 
24
- def run: () -> (1 | 0)
24
+ def run: () -> Integer
25
25
  end
26
26
  end
27
27
  end
@@ -1,7 +1,13 @@
1
1
  module Steep
2
2
  module PathHelper
3
+ # Receives a String that represents a *file* URI and returns a Pathname
4
+ #
5
+ # Returns `nil` when the schema of given URI is not `file://`.
6
+ #
3
7
  def self?.to_pathname: (String uri, ?dosish: bool) -> Pathname?
4
8
 
9
+ # Receives a Pathname and returns a *file* URI
10
+ #
5
11
  def self?.to_uri: (Pathname path, ?dosish: bool) -> URI::File
6
12
  end
7
13
  end
data/steep.gemspec CHANGED
@@ -33,8 +33,13 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "rainbow", ">= 2.2.2", "< 4.0"
34
34
  spec.add_runtime_dependency "listen", "~> 3.0"
35
35
  spec.add_runtime_dependency "language_server-protocol", ">= 3.15", "< 4.0"
36
- spec.add_runtime_dependency "rbs", ">= 2.7.0.pre"
36
+ spec.add_runtime_dependency "rbs", ">= 2.7.0"
37
37
  spec.add_runtime_dependency "parallel", ">= 1.0.0"
38
38
  spec.add_runtime_dependency "terminal-table", ">= 2", "< 4"
39
39
  spec.add_runtime_dependency "securerandom", ">= 0.1"
40
+ spec.add_runtime_dependency "json", ">= 2.1.0"
41
+ spec.add_runtime_dependency "logger", ">= 1.3.0"
42
+ spec.add_runtime_dependency "fileutils", ">= 1.1.0"
43
+ spec.add_runtime_dependency "strscan", ">= 1.0.0"
44
+ spec.add_runtime_dependency "csv", ">= 3.0.9"
40
45
  end
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.2.0.pre.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-06 00:00:00.000000000 Z
11
+ date: 2022-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 2.7.0.pre
101
+ version: 2.7.0
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 2.7.0.pre
108
+ version: 2.7.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: parallel
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +154,76 @@ dependencies:
154
154
  - - ">="
155
155
  - !ruby/object:Gem::Version
156
156
  version: '0.1'
157
+ - !ruby/object:Gem::Dependency
158
+ name: json
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: 2.1.0
164
+ type: :runtime
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 2.1.0
171
+ - !ruby/object:Gem::Dependency
172
+ name: logger
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 1.3.0
178
+ type: :runtime
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: 1.3.0
185
+ - !ruby/object:Gem::Dependency
186
+ name: fileutils
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: 1.1.0
192
+ type: :runtime
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: 1.1.0
199
+ - !ruby/object:Gem::Dependency
200
+ name: strscan
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: 1.0.0
206
+ type: :runtime
207
+ prerelease: false
208
+ version_requirements: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: 1.0.0
213
+ - !ruby/object:Gem::Dependency
214
+ name: csv
215
+ requirement: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - ">="
218
+ - !ruby/object:Gem::Version
219
+ version: 3.0.9
220
+ type: :runtime
221
+ prerelease: false
222
+ version_requirements: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: 3.0.9
157
227
  description: Gradual Typing for Ruby
158
228
  email:
159
229
  - matsumoto@soutaro.com
@@ -225,7 +295,7 @@ files:
225
295
  - lib/steep/drivers/print_project.rb
226
296
  - lib/steep/drivers/stats.rb
227
297
  - lib/steep/drivers/utils/driver_helper.rb
228
- - lib/steep/drivers/utils/jobs_count.rb
298
+ - lib/steep/drivers/utils/jobs_option.rb
229
299
  - lib/steep/drivers/validate.rb
230
300
  - lib/steep/drivers/vendor.rb
231
301
  - lib/steep/drivers/watch.rb
@@ -303,6 +373,7 @@ files:
303
373
  - sample/sig/conference.rbs
304
374
  - sample/sig/length.rbs
305
375
  - sig/shims/language-server_protocol.rbs
376
+ - sig/shims/parallel.rbs
306
377
  - sig/shims/parser.rbs
307
378
  - sig/shims/parser/source/map.rbs
308
379
  - sig/shims/parser/source/range.rbs
@@ -333,6 +404,7 @@ files:
333
404
  - sig/steep/ast/types/union.rbs
334
405
  - sig/steep/ast/types/var.rbs
335
406
  - sig/steep/ast/types/void.rbs
407
+ - sig/steep/cli.rbs
336
408
  - sig/steep/diagnostic/deprecated/unknown_constant_assigned.rbs
337
409
  - sig/steep/diagnostic/helper.rbs
338
410
  - sig/steep/diagnostic/lsp_formatter.rbs
@@ -347,7 +419,7 @@ files:
347
419
  - sig/steep/drivers/print_project.rbs
348
420
  - sig/steep/drivers/stats.rbs
349
421
  - sig/steep/drivers/utils/driver_helper.rbs
350
- - sig/steep/drivers/utils/jobs_count.rbs
422
+ - sig/steep/drivers/utils/jobs_option.rbs
351
423
  - sig/steep/drivers/validate.rbs
352
424
  - sig/steep/drivers/vendor.rbs
353
425
  - sig/steep/drivers/watch.rbs
@@ -682,11 +754,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
682
754
  version: 2.6.0
683
755
  required_rubygems_version: !ruby/object:Gem::Requirement
684
756
  requirements:
685
- - - ">"
757
+ - - ">="
686
758
  - !ruby/object:Gem::Version
687
- version: 1.3.1
759
+ version: '0'
688
760
  requirements: []
689
- rubygems_version: 3.3.3
761
+ rubygems_version: 3.3.7
690
762
  signing_key:
691
763
  specification_version: 4
692
764
  summary: Gradual Typing for Ruby
@@ -1,9 +0,0 @@
1
- module Steep
2
- module Drivers
3
- module Utils
4
- module JobsCount
5
- attr_accessor :jobs_count, :steep_command
6
- end
7
- end
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- module Steep
2
- module Drivers
3
- module Utils
4
- module JobsCount
5
- attr_accessor jobs_count: Integer
6
-
7
- attr_accessor steep_command: String
8
- end
9
- end
10
- end
11
- end