steep 1.7.1 → 1.8.0.dev.2

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: 6031a713ec97be707b33a667121cba53ba966e30c0949c1070c62ccf4c698596
4
- data.tar.gz: 01cd81e06eb1228a4b01070e0f6a12098fe10ee2cfe7620434a629f70e504005
3
+ metadata.gz: eff62e36ae34f76bafc5eb5ec8425ba373dd9ab64ae880537d65b96b4581970c
4
+ data.tar.gz: b0dc7b3d10b83a0e188a211f40c3a91eb3e146138da328079c84639b92c87bb8
5
5
  SHA512:
6
- metadata.gz: abfac9447afb1c68ba1702738f1ffd67c9b2cddc860a84a4552b963eafd3e9936987c2085d25b565b8834bc70be49bf5271daa28ac02926db12a5d056cc0780b
7
- data.tar.gz: '0871a287d3bc466c58a9106def0ed944e682c862f5ab30d849cfd9dfdcbd9aefb49b376791c6a61211f0cfefef000d05f62e7b0ce3a5045faf9f2f9a39eadc0d'
6
+ metadata.gz: 6e5d7e9e19bf782a8a03842eed077030a9f72eeb5f570ef23110658916f2d4c93c1090e3f3f6017957c80ef1a74c4c7a33bbc295316fe4afb47309cf47c2bcac
7
+ data.tar.gz: 66a14f3ec60c294a90e85bde099eb40224f22a99493f121bd8378e288affd7ad32a7ee8e1aff23915dd373768c4a35657fd92e14c7afe9e9cbe244c18d36d96c
data/README.md CHANGED
@@ -214,8 +214,9 @@ You can find examples in `smoke` directory.
214
214
  ## IDEs
215
215
 
216
216
  Steep implements some of the Language Server Protocol features.
217
- - For **VSCode** please install [the plugin](https://github.com/soutaro/steep-vscode)
218
- - For **SublimeText** please install [LSP](https://github.com/sublimelsp/LSP) package and follow [instructions](https://lsp.sublimetext.io/language_servers/#steep)
217
+ - For **VSCode** please install [the plugin](https://github.com/soutaro/steep-vscode).
218
+ - For **SublimeText** please install [LSP](https://github.com/sublimelsp/LSP) package and follow [instructions](https://lsp.sublimetext.io/language_servers/#steep).
219
+ - For **Vim** or **Neovim** please install [ALE](https://github.com/dense-analysis/ale?tab=readme-ov-file#asynchronous-lint-engine). You may want to `let g:ale_ruby_steep_executable = 'bundle'` to use your bundled `steep` version.
219
220
 
220
221
  Other LSP supporting tools may work with Steep where it starts the server as `steep langserver`.
221
222
 
@@ -16,7 +16,7 @@ You have to edit your `Gemfile`. Specify `require: false` for gems for which you
16
16
 
17
17
  ```ruby
18
18
  gem 'rbs', require: false
19
- gem 'steep, require: false
19
+ gem 'steep', require: false
20
20
  gem 'rbs_rails', require: false
21
21
  gem 'rbs_protobuf', require: false
22
22
  ```
@@ -162,7 +162,7 @@ module Steep
162
162
  end
163
163
 
164
164
  loc = if send
165
- send.loc.selector.with(end_pos: send.loc.expression.end_pos)
165
+ send.loc.selector.with(end_pos: send.loc.expression.end_pos) # steep:ignore NoMethod
166
166
  else
167
167
  node.loc.expression
168
168
  end
@@ -213,7 +213,7 @@ module Steep
213
213
  end
214
214
 
215
215
  loc = if send
216
- send.loc.selector.with(end_pos: send.loc.expression.end_pos)
216
+ send.loc.selector.with(end_pos: send.loc.expression.end_pos) # steep:ignore NoMethod
217
217
  else
218
218
  node.loc.expression
219
219
  end
@@ -287,8 +287,8 @@ module Steep
287
287
  loc = case node.type
288
288
  when :send
289
289
  loc = _ = nil
290
- loc ||= node.loc.operator if node.loc.respond_to?(:operator)
291
- loc ||= node.loc.selector if node.loc.respond_to?(:selector)
290
+ loc ||= node.loc.operator if node.loc.respond_to?(:operator) # steep:ignore NoMethod
291
+ loc ||= node.loc.selector if node.loc.respond_to?(:selector) # steep:ignore NoMethod
292
292
  loc
293
293
  when :block
294
294
  node.children[0].loc.selector
@@ -463,7 +463,7 @@ module Steep
463
463
  node.children[1]
464
464
  when :defs
465
465
  node.children[2]
466
- end
466
+ end #: Parser::AST::Node?
467
467
  super(node: node, location: args&.loc&.expression || node.loc.name)
468
468
  @method_type = method_type
469
469
  end
@@ -668,7 +668,7 @@ module Steep
668
668
  attr_reader :name
669
669
 
670
670
  def initialize(node:, name:)
671
- super(node: node, location: node.loc.name)
671
+ super(node: node, location: node.loc.name) # steep:ignore NoMethod
672
672
  @name = name
673
673
  end
674
674
 
@@ -464,9 +464,11 @@ module Steep
464
464
 
465
465
  if (items, index = provider.run(line: job.line, column: job.column))
466
466
  signatures = items.map do |item|
467
+ params = item.parameters or raise
468
+
467
469
  LSP::Interface::SignatureInformation.new(
468
470
  label: item.method_type.to_s,
469
- parameters: item.parameters.map { |param| LSP::Interface::ParameterInformation.new(label: param)},
471
+ parameters: params.map { |param| LSP::Interface::ParameterInformation.new(label: param)},
470
472
  active_parameter: item.active_parameter,
471
473
  documentation: item.comment&.yield_self do |comment|
472
474
  LSP::Interface::MarkupContent.new(
@@ -39,7 +39,7 @@ module Steep
39
39
  end
40
40
 
41
41
  def percentage
42
- checked_paths.size * 100 / all_paths.size
42
+ checked_paths.size * 100 / total
43
43
  end
44
44
 
45
45
  def all_paths
@@ -58,7 +58,7 @@ module Steep
58
58
  end
59
59
 
60
60
  def finished?
61
- unchecked_paths.empty?
61
+ total <= checked_paths.size
62
62
  end
63
63
 
64
64
  def unchecked_paths
@@ -173,7 +173,9 @@ module Steep
173
173
  method: :"textDocument/publishDiagnostics",
174
174
  params: LSP::Interface::PublishDiagnosticsParams.new(
175
175
  uri: Steep::PathHelper.to_uri(job.path).to_s,
176
- diagnostics: diagnostics.map {|diagnostic| formatter.format(diagnostic) }.uniq
176
+ diagnostics: diagnostics.map {|diagnostic|
177
+ _ = formatter.format(diagnostic)
178
+ }.uniq
177
179
  )
178
180
  )
179
181
  end
@@ -191,7 +193,7 @@ module Steep
191
193
  method: :"textDocument/publishDiagnostics",
192
194
  params: LSP::Interface::PublishDiagnosticsParams.new(
193
195
  uri: Steep::PathHelper.to_uri(job.path).to_s,
194
- diagnostics: diagnostics.map {|diagnostic| formatter.format(diagnostic) }.uniq.compact
196
+ diagnostics: diagnostics.map {|diagnostic| _ = formatter.format(diagnostic) }.uniq.compact
195
197
  )
196
198
  )
197
199
  end
@@ -210,7 +212,9 @@ module Steep
210
212
  method: :"textDocument/publishDiagnostics",
211
213
  params: LSP::Interface::PublishDiagnosticsParams.new(
212
214
  uri: Steep::PathHelper.to_uri(job.path).to_s,
213
- diagnostics: diagnostics.map {|diagnostic| formatter.format(diagnostic) }.uniq.compact
215
+ diagnostics: diagnostics.map {|diagnostic|
216
+ _ = formatter.format(diagnostic)
217
+ }.uniq.compact
214
218
  )
215
219
  )
216
220
  end
@@ -132,7 +132,7 @@ module Steep
132
132
  new(reader: reader, writer: writer, stderr: stderr, wait_thread: thread, name: name, index: index&.[](1))
133
133
  end
134
134
 
135
- def self.start_typecheck_workers(steepfile:, args:, steep_command:, count: [Etc.nprocessors - 1, 1].max, delay_shutdown: false)
135
+ def self.start_typecheck_workers(steepfile:, args:, steep_command:, count: [Etc.nprocessors - 1, 1].max || raise, delay_shutdown: false)
136
136
  count.times.map do |i|
137
137
  start_worker(
138
138
  :typecheck,
@@ -725,7 +725,7 @@ module Steep
725
725
  end
726
726
 
727
727
  def keyword_argument_items_for_method(call_node:, send_node:, position:, prefix:, items:)
728
- receiver_node, method_name, argument_nodes = deconstruct_send_node!(send_node)
728
+ _receiver_node, _method_name, argument_nodes = deconstruct_send_node!(send_node)
729
729
 
730
730
  call = typing.call_of(node: call_node)
731
731
 
@@ -733,6 +733,7 @@ module Steep
733
733
  when TypeInference::MethodCall::Typed, TypeInference::MethodCall::Error
734
734
  context = typing.context_at(line: position.line, column: position.column)
735
735
  type = call.receiver_type
736
+ type = type.subst(Interface::Substitution.build([], self_type: context.self_type, module_type: context.module_context&.module_type, instance_type: context.module_context&.instance_type))
736
737
 
737
738
  config = Interface::Builder::Config.new(self_type: type, variable_bounds: context.variable_context.upper_bounds)
738
739
  if shape = subtyping.builder.shape(type, config)
@@ -745,7 +746,12 @@ module Steep
745
746
  kwargs = argument_nodes.find { |arg| arg.type == :kwargs }&.children || []
746
747
  used_kwargs = kwargs.filter_map { |arg| arg.type == :pair && arg.children.first.children.first }
747
748
 
748
- kwargs = defn.type.type.required_keywords.keys + defn.type.type.optional_keywords.keys
749
+ if defn.type.type.is_a?(RBS::Types::UntypedFunction)
750
+ kwargs = [] #: Array[Symbol]
751
+ else
752
+ kwargs = defn.type.type.required_keywords.keys + defn.type.type.optional_keywords.keys
753
+ end
754
+
749
755
  kwargs.each do |name|
750
756
  if name.to_s.start_with?(prefix) && !used_kwargs.include?(name)
751
757
  items << KeywordArgumentItem.new(identifier: "#{name}:", range: range)
@@ -121,14 +121,24 @@ module Steep
121
121
  context = typing.context_at(line: line, column: column)
122
122
  var_type = context.type_env[var_name] || AST::Types::Any.new(location: nil)
123
123
 
124
- return VariableContent.new(node: node, name: var_name, type: var_type, location: node.location.name)
124
+ return VariableContent.new(
125
+ node: node,
126
+ name: var_name,
127
+ type: var_type,
128
+ location: node.location.name # steep:ignore NoMethod
129
+ )
125
130
 
126
131
  when :lvasgn
127
132
  var_name, rhs = node.children
128
133
  context = typing.context_at(line: line, column: column)
129
134
  type = context.type_env[var_name] || typing.type_of(node: node)
130
135
 
131
- return VariableContent.new(node: node, name: var_name, type: type, location: node.location.name)
136
+ return VariableContent.new(
137
+ node: node,
138
+ name: var_name,
139
+ type: type,
140
+ location: node.location.name # steep:ignore NoMethod
141
+ )
132
142
 
133
143
  when :send, :csend
134
144
  result_node =
@@ -149,7 +159,7 @@ module Steep
149
159
  return MethodCallContent.new(
150
160
  node: result_node,
151
161
  method_call: call,
152
- location: node.location.selector
162
+ location: node.location.selector # steep:ignore NoMethod
153
163
  )
154
164
  end
155
165
  end
@@ -159,13 +169,15 @@ module Steep
159
169
  method_context = context.method_context
160
170
 
161
171
  if method_context && method_context.method
162
- return DefinitionContent.new(
163
- node: node,
164
- method_name: method_name_from_method(method_context, builder: context.factory.definition_builder),
165
- method_type: method_context.method_type,
166
- definition: method_context.method,
167
- location: node.loc.name
168
- )
172
+ if method_context.method_type
173
+ return DefinitionContent.new(
174
+ node: node,
175
+ method_name: method_name_from_method(method_context, builder: context.factory.definition_builder),
176
+ method_type: method_context.method_type,
177
+ definition: method_context.method,
178
+ location: node.loc.name # steep:ignore NoMethod
179
+ )
180
+ end
169
181
  end
170
182
 
171
183
  when :const, :casgn
@@ -178,7 +190,7 @@ module Steep
178
190
  entry = context.env.constant_entry(const_name) or return
179
191
 
180
192
  return ConstantContent.new(
181
- location: node.location.name,
193
+ location: node.location.name, # steep:ignore NoMethod
182
194
  full_name: const_name,
183
195
  type: type,
184
196
  decl: entry
@@ -11,7 +11,7 @@ module Steep
11
11
  arguments = [] #: Array[String]
12
12
  arguments.push(*method_type.type.required_positionals.map(&:to_s))
13
13
  arguments.push(*method_type.type.optional_positionals.map {|p| "?#{p}"})
14
- arguments.push("*#{self.method_type.type.rest_positionals}") if method_type.type.rest_positionals
14
+ arguments.push("*#{method_type.type.rest_positionals}") if method_type.type.rest_positionals
15
15
  arguments.push(*method_type.type.trailing_positionals.map(&:to_s))
16
16
  arguments.push(*method_type.type.required_keywords.map {|name, param| "#{name}: #{param}" })
17
17
  arguments.push(*method_type.type.optional_keywords.map {|name, param| "?#{name}: #{param}" })
@@ -136,6 +136,7 @@ module Steep
136
136
 
137
137
  def active_parameter_for(method_type, argument_nodes, last_argument_nodes, node)
138
138
  return unless method_type
139
+ return unless method_type.type.is_a?(RBS::Types::Function)
139
140
 
140
141
  positionals = method_type.type.required_positionals.size + method_type.type.optional_positionals.size + (method_type.type.rest_positionals ? 1 : 0) + method_type.type.trailing_positionals.size
141
142
 
@@ -139,8 +139,11 @@ module Steep
139
139
 
140
140
  case service.status
141
141
  when SignatureService::SyntaxErrorStatus, SignatureService::AncestorErrorStatus
142
- service.status.diagnostics.group_by {|diag| Pathname(diag.location.buffer.name) }.each do |path, diagnostics|
143
- signature_diagnostics[path].push(*diagnostics)
142
+ service.status.diagnostics.group_by {|diag| diag.location&.buffer&.name&.to_s }.each do |path_string, diagnostics|
143
+ if path_string
144
+ path = Pathname(path_string)
145
+ signature_diagnostics[path].push(*diagnostics)
146
+ end
144
147
  end
145
148
  when SignatureService::LoadedStatus
146
149
  validation_diagnostics = signature_validation_diagnostics[target.name] || {}
@@ -230,6 +233,7 @@ module Steep
230
233
  case service.status
231
234
  when SignatureService::SyntaxErrorStatus
232
235
  diagnostics = service.status.diagnostics.select do |diag|
236
+ diag.location or raise
233
237
  Pathname(diag.location.buffer.name) == path &&
234
238
  (diag.is_a?(Diagnostic::Signature::SyntaxError) || diag.is_a?(Diagnostic::Signature::UnexpectedError))
235
239
  end
@@ -239,12 +243,15 @@ module Steep
239
243
  end
240
244
 
241
245
  when SignatureService::AncestorErrorStatus
242
- diagnostics = service.status.diagnostics.select {|diag| Pathname(diag.location.buffer.name) == path }
246
+ diagnostics = service.status.diagnostics.select do |diag|
247
+ diag.location or raise
248
+ Pathname(diag.location.buffer.name) == path
249
+ end
243
250
  accumulated_diagnostics.push(*diagnostics)
244
251
  yield [path, accumulated_diagnostics]
245
252
 
246
253
  when SignatureService::LoadedStatus
247
- validator = Signature::Validator.new(checker: service.current_subtyping)
254
+ validator = Signature::Validator.new(checker: service.current_subtyping || raise)
248
255
  type_names = service.type_names(paths: Set[path], env: service.latest_env).to_set
249
256
 
250
257
  unless type_names.empty?
@@ -286,7 +293,10 @@ module Steep
286
293
  end
287
294
  end
288
295
 
289
- diagnostics = validator.each_error.select {|error| Pathname(error.location.buffer.name) == path }
296
+ diagnostics = validator.each_error.select do |error|
297
+ error.location or raise
298
+ Pathname(error.location.buffer.name) == path
299
+ end
290
300
  accumulated_diagnostics.push(*diagnostics)
291
301
  yield [path, accumulated_diagnostics]
292
302
  end
@@ -361,7 +371,7 @@ module Steep
361
371
  error = Diagnostic::Ruby::SyntaxError.new(message: exn.message, location: exn.location)
362
372
  SourceFile.with_syntax_error(path: path, content: text, error: error)
363
373
  rescue ::Parser::SyntaxError => exn
364
- error = Diagnostic::Ruby::SyntaxError.new(message: exn.message, location: exn.diagnostic.location)
374
+ error = Diagnostic::Ruby::SyntaxError.new(message: exn.message, location: (_ = exn).diagnostic.location)
365
375
  SourceFile.with_syntax_error(path: path, content: text, error: error)
366
376
  rescue EncodingError => exn
367
377
  SourceFile.no_data(path: path, content: "")
data/lib/steep/source.rb CHANGED
@@ -8,6 +8,7 @@ module Steep
8
8
  attr_reader :ignores
9
9
 
10
10
  extend NodeHelper
11
+ extend ModuleHelper
11
12
 
12
13
  def initialize(buffer:, path:, node:, mapping:, comments:, ignores:)
13
14
  @buffer = buffer
@@ -295,8 +296,14 @@ module Steep
295
296
  end
296
297
 
297
298
  def annotations(block:, factory:, context:)
299
+ annotations =
300
+ if block
301
+ mapping.fetch(block, [])
302
+ else
303
+ []
304
+ end #: Array[AST::Annotation::t]
298
305
  AST::Annotation::Collection.new(
299
- annotations: (mapping[block] || []),
306
+ annotations: annotations,
300
307
  factory: factory,
301
308
  context: context
302
309
  )
@@ -444,6 +451,32 @@ module Steep
444
451
  end
445
452
  end
446
453
 
454
+ def self.skip_arg_assertions(node)
455
+ send_node, _ = deconstruct_sendish_and_block_nodes(node)
456
+ return false unless send_node
457
+
458
+ if send_node.type == :send
459
+ receiver, method, args = deconstruct_send_node!(send_node)
460
+
461
+ return false unless receiver
462
+
463
+ if receiver.type == :const
464
+ if type_name = module_name_from_node(receiver.children[0], receiver.children[1])
465
+ if type_name.namespace.empty?
466
+ if type_name.name == :Data && method == :define
467
+ return true
468
+ end
469
+ if type_name.name == :Struct && method == :new
470
+ return true
471
+ end
472
+ end
473
+ end
474
+ end
475
+ end
476
+
477
+ false
478
+ end
479
+
447
480
  def self.insert_type_node(node, comments)
448
481
  if node.location.expression
449
482
  first_line = node.location.expression.first_line
@@ -459,12 +492,14 @@ module Steep
459
492
  case node.type
460
493
  when :lvasgn, :ivasgn, :gvasgn, :cvasgn, :casgn
461
494
  # Skip
495
+ when :return, :break, :next
496
+ # Skip
497
+ when :def, :defs
498
+ # Skip
462
499
  when :masgn
463
500
  lhs, rhs = node.children
464
501
  node = node.updated(nil, [lhs, insert_type_node(rhs, comments)])
465
502
  return adjust_location(node)
466
- when :return, :break, :next
467
- # Skip
468
503
  when :begin
469
504
  location = node.loc #: Parser::Source::Map & Parser::AST::_Collection
470
505
  if location.begin
@@ -475,6 +510,15 @@ module Steep
475
510
  return assertion_node(node, last_comment)
476
511
  end
477
512
  else
513
+ if (receiver, name, * = deconstruct_send_node(node))
514
+ if receiver.nil?
515
+ if name == :attr_reader || name == :attr_writer || name == :attr_accessor
516
+ child_assertions = comments.except(last_line)
517
+ node = map_child_node(node) {|child| insert_type_node(child, child_assertions) }
518
+ return adjust_location(node)
519
+ end
520
+ end
521
+ end
478
522
  child_assertions = comments.except(last_line)
479
523
  node = map_child_node(node) {|child| insert_type_node(child, child_assertions) }
480
524
  node = adjust_location(node)
@@ -540,7 +584,35 @@ module Steep
540
584
  ]
541
585
  )
542
586
  )
587
+ when :def
588
+ name, args, body = node.children
589
+ assertion_location = args&.location&.expression || (_ = node.location).name
590
+ no_assertion_comments = comments.except(assertion_location.last_line)
591
+ args = insert_type_node(args, no_assertion_comments)
592
+ body = insert_type_node(body, comments) if body
593
+ return adjust_location(node.updated(nil, [name, args, body]))
594
+ when :defs
595
+ object, name, args, body = node.children
596
+ assertion_location = args&.location&.expression || (_ = node.location).name
597
+ no_assertion_comments = comments.except(assertion_location.last_line)
598
+ object = insert_type_node(object, no_assertion_comments)
599
+ args = insert_type_node(args, no_assertion_comments)
600
+ body = insert_type_node(body, comments) if body
601
+ return adjust_location(node.updated(nil, [object, name, args, body]))
543
602
  else
603
+ if skip_arg_assertions(node)
604
+ # Data.define, Struct.new, ...??
605
+ if node.location.expression
606
+ first_line = node.location.expression.first_line
607
+ last_line = node.location.expression.last_line
608
+
609
+ child_assertions = comments.delete_if {|line, _ | first_line < line && line < last_line }
610
+ node = map_child_node(node) {|child| insert_type_node(child, child_assertions) }
611
+
612
+ return adjust_location(node)
613
+ end
614
+ end
615
+
544
616
  adjust_location(
545
617
  map_child_node(node, nil) {|child| insert_type_node(child, comments) }
546
618
  )
@@ -28,7 +28,7 @@ module Steep
28
28
  attr_reader :lower_bound
29
29
  attr_reader :upper_bound
30
30
 
31
- def initialize(var: nil, lower_bound: nil, upper_bound: nil)
31
+ def initialize(var:, lower_bound:, upper_bound:)
32
32
  @var = var
33
33
  @lower_bound = lower_bound
34
34
  @upper_bound = upper_bound
@@ -96,7 +96,7 @@ module Steep
96
96
  unless Set.new(vars).disjoint?(unknowns)
97
97
  raise UnsatisfiedInvariantError.new(
98
98
  reason: UnsatisfiedInvariantError::VariablesUnknownsNotDisjoint.new(vars: vars),
99
- constraints: constraints
99
+ constraints: self
100
100
  )
101
101
  end
102
102
  end
@@ -1375,6 +1375,12 @@ module Steep
1375
1375
  when :float
1376
1376
  add_typing(node, type: AST::Builtin::Float.instance_type)
1377
1377
 
1378
+ when :rational
1379
+ add_typing(node, type: AST::Types::Name::Instance.new(name: TypeName("::Rational"), args: []))
1380
+
1381
+ when :complex
1382
+ add_typing(node, type: AST::Types::Name::Instance.new(name: TypeName("::Complex"), args: []))
1383
+
1378
1384
  when :nil
1379
1385
  add_typing(node, type: AST::Builtin.nil_type)
1380
1386
 
@@ -172,6 +172,9 @@ module Steep
172
172
  end
173
173
 
174
174
  def params_type0(hint:)
175
+ # @type var leadings: Array[AST::Types::t]
176
+ # @type var optionals: Array[AST::Types::t]
177
+
175
178
  if hint
176
179
  case
177
180
  when leading_params.size == hint.required.size
data/lib/steep/typing.rb CHANGED
@@ -110,13 +110,13 @@ module Steep
110
110
  begin_pos = if send_node.type != :lambda && args_node.loc.expression
111
111
  args_node.loc.expression.end_pos
112
112
  else
113
- node.loc.begin.end_pos
113
+ node.loc.begin.end_pos # steep:ignore NoMethod
114
114
  end
115
- end_pos = node.loc.end.begin_pos
115
+ end_pos = node.loc.end.begin_pos # steep:ignore NoMethod
116
116
  when :numblock
117
117
  send_node, _ = node.children
118
- begin_pos = node.loc.begin.end_pos
119
- end_pos = node.loc.end.begin_pos
118
+ begin_pos = node.loc.begin.end_pos # steep:ignore NoMethod
119
+ end_pos = node.loc.end.begin_pos # steep:ignore NoMethod
120
120
  end
121
121
 
122
122
  begin_pos..end_pos
@@ -131,20 +131,20 @@ module Steep
131
131
  else
132
132
  name_node.loc.expression.end_pos
133
133
  end
134
- end_pos = node.loc.end.begin_pos
134
+ end_pos = node.loc.end.begin_pos # steep:ignore NoMethod
135
135
 
136
136
  add_context(begin_pos..end_pos, context: context)
137
137
 
138
138
  when :module
139
139
  name_node = node.children[0]
140
140
  begin_pos = name_node.loc.expression.end_pos
141
- end_pos = node.loc.end.begin_pos
141
+ end_pos = node.loc.end.begin_pos # steep:ignore NoMethod
142
142
  add_context(begin_pos..end_pos, context: context)
143
143
 
144
144
  when :sclass
145
145
  name_node = node.children[0]
146
146
  begin_pos = name_node.loc.expression.end_pos
147
- end_pos = node.loc.end.begin_pos
147
+ end_pos = node.loc.end.begin_pos # steep:ignore NoMethod
148
148
  add_context(begin_pos..end_pos, context: context)
149
149
 
150
150
  when :def, :defs
@@ -159,20 +159,20 @@ module Steep
159
159
 
160
160
  body_begin_pos =
161
161
  case
162
- when node.loc.assignment
162
+ when node.loc.assignment # steep:ignore NoMethod
163
163
  # endless def
164
- node.loc.assignment.end_pos
164
+ node.loc.assignment.end_pos # steep:ignore NoMethod
165
165
  when args_node.loc.expression
166
166
  # with args
167
167
  args_node.loc.expression.end_pos
168
168
  else
169
169
  # without args
170
- node.loc.name.end_pos
170
+ node.loc.name.end_pos # steep:ignore NoMethod
171
171
  end
172
172
 
173
173
  body_end_pos =
174
- if node.loc.end
175
- node.loc.end.begin_pos
174
+ if node.loc.end # steep:ignore NoMethod
175
+ node.loc.end.begin_pos # steep:ignore NoMethod
176
176
  else
177
177
  node.loc.expression.end_pos
178
178
  end
@@ -188,7 +188,7 @@ module Steep
188
188
  _, collection, _ = node.children
189
189
 
190
190
  begin_pos = collection.loc.expression.end_pos
191
- end_pos = node.loc.end.begin_pos
191
+ end_pos = node.loc.end.begin_pos # steep:ignore NoMethod
192
192
 
193
193
  add_context(begin_pos..end_pos, context: context)
194
194
  else
@@ -202,6 +202,7 @@ module Steep
202
202
  end
203
203
 
204
204
  def dump(io)
205
+ # steep:ignore:start
205
206
  io.puts "Typing: "
206
207
  nodes.each_value do |node|
207
208
  io.puts " #{Typing.summary(node)} => #{type_of(node: node).inspect}"
@@ -211,6 +212,7 @@ module Steep
211
212
  errors.each do |error|
212
213
  io.puts " #{Typing.summary(error.node)} => #{error.inspect}"
213
214
  end
215
+ # steep:ignore:end
214
216
  end
215
217
 
216
218
  def self.summary(node)
data/lib/steep/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steep
2
- VERSION = "1.7.1"
2
+ VERSION = "1.8.0.dev.2"
3
3
  end
data/lib/steep.rb CHANGED
@@ -76,11 +76,11 @@ require "steep/diagnostic/ruby"
76
76
  require "steep/diagnostic/signature"
77
77
  require "steep/diagnostic/lsp_formatter"
78
78
  require "steep/signature/validator"
79
+ require "steep/module_helper"
79
80
  require "steep/source"
80
81
  require "steep/source/ignore_ranges"
81
82
  require "steep/annotation_parser"
82
83
  require "steep/typing"
83
- require "steep/module_helper"
84
84
  require "steep/type_construction"
85
85
  require "steep/type_inference/context"
86
86
  require "steep/type_inference/context_array"
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.7.1
4
+ version: 1.8.0.dev.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
401
  - !ruby/object:Gem::Version
402
402
  version: '0'
403
403
  requirements: []
404
- rubygems_version: 3.5.3
404
+ rubygems_version: 3.5.11
405
405
  signing_key:
406
406
  specification_version: 4
407
407
  summary: Gradual Typing for Ruby