rbs-trace 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f0c689aa7e7519cd2ba4338c195c39dad1baa4022c96ed79b091b7e0051ba4a
4
- data.tar.gz: 22b18905f9ae5b4a4cc3a9714a8db2b0289d822730752942dfa2aa1160864ed8
3
+ metadata.gz: e587e127bc2689a2d6e3c9f25dad32a5b75b49164b8666d0c0ff891d9c6e35f4
4
+ data.tar.gz: 47cb65ce7cef30a14cc68984e7a76614ca593a1581a439b34341386937c65591
5
5
  SHA512:
6
- metadata.gz: 83ba38515e5363c85fb866709e063de85211e4c5b61dc9ff08277aa7e805f7fa92a7e9d515cf6b6786980b6f791f8f04517fc447971c62f85fa3d2189da2dbdb
7
- data.tar.gz: 91eb1069c5e6fe40d6fcda2f8f0ac07bf63e34dc59492322e102335f294ab6cd52cd5b3b7a1ad6574e2eb04c2630951305d8ab910ff2c85e80195dcc33fef11e
6
+ metadata.gz: 3ccd45b222189e14609f8ef30f207341dbf6a4ed863a4c94b5cf051d28504f84cd8d101a68905de787ac5661f9bc7b9432162b81abbda85868e40e14cc741ebd
7
+ data.tar.gz: 158f74515cad425793edcc6f7d68c2ee8140afb36d9922ee80b6d1c21c020db748c9842c9b3bc6c15d330c2a12834681c6082b3e373c9ae669ccc379337ed626
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.2] - 2024-12-29
4
+
5
+ - fix: Do not insert comments if comment `#:` exists
6
+
3
7
  ## [0.3.1] - 2024-10-19
4
8
 
5
9
  - fix: Fix the number of types specified in generics
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ [![Gem Version](https://badge.fury.io/rb/rbs-trace.svg)](https://badge.fury.io/rb/rbs-trace)
2
+ [![Test](https://github.com/sinsoku/rbs-trace/actions/workflows/test.yml/badge.svg)](https://github.com/sinsoku/rbs-trace/actions/workflows/test.yml)
3
+
1
4
  # RBS::Trace
2
5
 
3
6
  RBS::Trace collects argument types and return value types using TracePoint, and inserts inline RBS type declarations into files.
data/Rakefile CHANGED
@@ -19,9 +19,4 @@ task :steep do
19
19
  sh "steep check"
20
20
  end
21
21
 
22
- default = if RUBY_VERSION.start_with?("3.3")
23
- %i[spec rubocop rbs_inline steep]
24
- else
25
- %i[spec rubocop]
26
- end
27
- task(default:)
22
+ task(default: %i[spec rubocop rbs_inline steep])
@@ -44,9 +44,9 @@ module RBS
44
44
  # TODO: support block argument
45
45
  # @rbs () -> String
46
46
  def parameters_rbs
47
- converted = {}
47
+ converted = {} #: Hash[Symbol, Array[String?]]
48
48
  @parameters.each do |kind, name, klass|
49
- converted[kind] ||= []
49
+ converted[kind] ||= [] #: Array[String?]
50
50
  converted[kind] << convert(kind, name, klass)
51
51
  end
52
52
 
@@ -37,9 +37,13 @@ module RBS
37
37
 
38
38
  # @rbs (Array[String], Definition) -> boolish
39
39
  def skip_insert?(lines, definition)
40
- prev = definition.lineno - 2
40
+ current = definition.lineno - 1
41
+ prev = current - 1
41
42
 
42
- definition.decls.empty? || lines[prev]&.include?("# @rbs")
43
+ definition.decls.empty? ||
44
+ lines[prev]&.include?("# @rbs") ||
45
+ lines[prev]&.include?("#:") ||
46
+ lines[current]&.include?("#:")
43
47
  end
44
48
 
45
49
  # @rbs () -> Enumerator[Definition, void]
@@ -57,12 +57,14 @@ module RBS
57
57
  # @rbs (File, TracePoint) -> Definition
58
58
  def find_or_new_definition(file, tp)
59
59
  name = tp.method_id
60
- is_singleton = tp.defined_class.singleton_class?
60
+ is_singleton = tp.defined_class.singleton_class? # steep:ignore NoMethod
61
61
  klass = is_singleton ? tp.self : tp.defined_class
62
62
  mark = is_singleton ? "." : "#"
63
63
  signature = "#{klass}#{mark}#{name}"
64
64
 
65
+ # steep:ignore:start
65
66
  file.definitions[signature] ||= Definition.new(klass:, name:, lineno: tp.lineno)
67
+ # steep:ignore:end
66
68
  end
67
69
 
68
70
  # @rbs (TracePoint) -> void
@@ -84,7 +86,7 @@ module RBS
84
86
 
85
87
  # @rbs (TracePoint) -> void
86
88
  def call_event(tp) # rubocop:disable Metrics
87
- parameters = tp.parameters.filter_map do |kind, name|
89
+ parameters = tp.parameters.filter_map do |kind, name| # steep:ignore NoMethod
88
90
  # steep:ignore:start
89
91
  value = tp.binding.local_variable_get(name) if name && !%i[* ** &].include?(name)
90
92
  # steep:ignore:end
@@ -101,7 +103,9 @@ module RBS
101
103
  end
102
104
  [kind, name, klass]
103
105
  end
106
+ # steep:ignore:start
104
107
  stack_traces << Declaration.new(parameters, void: !assign_return_value?(tp.path, tp.method_id))
108
+ # steep:ignore:end
105
109
  end
106
110
 
107
111
  # @rbs (TracePoint, Definition) -> void
@@ -121,7 +125,7 @@ module RBS
121
125
 
122
126
  # @rbs (String) -> bool
123
127
  def ignore_path?(path)
124
- bundle_path = Bundler.bundle_path.to_s # steep:ignore UnknownConstant
128
+ bundle_path = Bundler.bundle_path.to_s # steep:ignore NoMethod
125
129
  ruby_lib_path = RbConfig::CONFIG["rubylibdir"]
126
130
 
127
131
  path.start_with?("<internal") ||
@@ -169,7 +173,7 @@ module RBS
169
173
  def parsed_nodes(path)
170
174
  return unless ::File.exist?(path)
171
175
 
172
- @parsed_nodes ||= {}
176
+ @parsed_nodes ||= {} #: Hash[String, Prism::ParseResult]
173
177
  @parsed_nodes[path] ||= Prism.parse_file(path)
174
178
  @parsed_nodes[path].value
175
179
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RBS
4
4
  module Trace
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.2"
6
6
  end
7
7
  end
@@ -6,13 +6,17 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: f18921b7bd1280daab3ab218b7e3939748515eb1
9
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: fileutils
13
13
  version: '0'
14
14
  source:
15
15
  type: stdlib
16
+ - name: json
17
+ version: '0'
18
+ source:
19
+ type: stdlib
16
20
  - name: logger
17
21
  version: '0'
18
22
  source:
@@ -21,8 +25,16 @@ gems:
21
25
  version: '0'
22
26
  source:
23
27
  type: stdlib
28
+ - name: optparse
29
+ version: '0'
30
+ source:
31
+ type: stdlib
32
+ - name: pathname
33
+ version: '0'
34
+ source:
35
+ type: stdlib
24
36
  - name: prism
25
- version: 0.30.0
37
+ version: 1.2.0
26
38
  source:
27
39
  type: rubygems
28
40
  - name: rake
@@ -30,7 +42,23 @@ gems:
30
42
  source:
31
43
  type: git
32
44
  name: ruby/gem_rbs_collection
33
- revision: f18921b7bd1280daab3ab218b7e3939748515eb1
45
+ revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
34
46
  remote: https://github.com/ruby/gem_rbs_collection.git
35
47
  repo_dir: gems
48
+ - name: rbs
49
+ version: 3.8.1
50
+ source:
51
+ type: rubygems
52
+ - name: rbs-inline
53
+ version: 0.10.0
54
+ source:
55
+ type: rubygems
56
+ - name: rdoc
57
+ version: '0'
58
+ source:
59
+ type: stdlib
60
+ - name: tsort
61
+ version: '0'
62
+ source:
63
+ type: stdlib
36
64
  gemfile_lock_path: Gemfile.lock
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs-trace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takumi Shotoku
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-19 00:00:00.000000000 Z
10
+ date: 2024-12-29 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: prism
@@ -41,8 +40,6 @@ files:
41
40
  - README.md
42
41
  - Rakefile
43
42
  - Steepfile
44
- - gemfiles/3.1.gemfile
45
- - gemfiles/3.1.gemfile.lock
46
43
  - lib/rbs-trace.rb
47
44
  - lib/rbs/trace.rb
48
45
  - lib/rbs/trace/declaration.rb
@@ -64,10 +61,9 @@ licenses:
64
61
  - MIT
65
62
  metadata:
66
63
  homepage_uri: https://github.com/sinsoku/rbs-trace
67
- source_code_uri: https://github.com/sinsoku/rbs-trace/tree/v0.3.1
68
- changelog_uri: https://github.com/sinsoku/rbs-trace/blob/v0.3.1/CHANGELOG.md
64
+ source_code_uri: https://github.com/sinsoku/rbs-trace/tree/v0.3.2
65
+ changelog_uri: https://github.com/sinsoku/rbs-trace/blob/v0.3.2/CHANGELOG.md
69
66
  rubygems_mfa_required: 'true'
70
- post_install_message:
71
67
  rdoc_options: []
72
68
  require_paths:
73
69
  - lib
@@ -82,8 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
78
  - !ruby/object:Gem::Version
83
79
  version: '0'
84
80
  requirements: []
85
- rubygems_version: 3.5.17
86
- signing_key:
81
+ rubygems_version: 3.6.2
87
82
  specification_version: 4
88
83
  summary: Automatically Insert inline RBS type declarations using runtime information.
89
84
  test_files: []
data/gemfiles/3.1.gemfile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in rbs-trace.gemspec
6
- gemspec(path: "..")
7
-
8
- gem "rake"
9
- gem "rspec"
10
- gem "rubocop", require: false
11
- gem "rubocop-rake", require: false
12
- gem "rubocop-rspec", require: false
@@ -1,68 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- rbs-trace (0.3.1)
5
- prism (>= 0.3.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- diff-lcs (1.5.1)
12
- json (2.7.2)
13
- language_server-protocol (3.17.0.3)
14
- parallel (1.26.3)
15
- parser (3.3.5.0)
16
- ast (~> 2.4.1)
17
- racc
18
- prism (1.0.0)
19
- racc (1.8.1)
20
- rainbow (3.1.1)
21
- rake (13.2.1)
22
- regexp_parser (2.9.2)
23
- rspec (3.13.0)
24
- rspec-core (~> 3.13.0)
25
- rspec-expectations (~> 3.13.0)
26
- rspec-mocks (~> 3.13.0)
27
- rspec-core (3.13.1)
28
- rspec-support (~> 3.13.0)
29
- rspec-expectations (3.13.3)
30
- diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.13.0)
32
- rspec-mocks (3.13.1)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.13.0)
35
- rspec-support (3.13.1)
36
- rubocop (1.66.1)
37
- json (~> 2.3)
38
- language_server-protocol (>= 3.17.0)
39
- parallel (~> 1.10)
40
- parser (>= 3.3.0.2)
41
- rainbow (>= 2.2.2, < 4.0)
42
- regexp_parser (>= 2.4, < 3.0)
43
- rubocop-ast (>= 1.32.2, < 2.0)
44
- ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 2.4.0, < 3.0)
46
- rubocop-ast (1.32.3)
47
- parser (>= 3.3.1.0)
48
- rubocop-rake (0.6.0)
49
- rubocop (~> 1.0)
50
- rubocop-rspec (3.0.5)
51
- rubocop (~> 1.61)
52
- ruby-progressbar (1.13.0)
53
- unicode-display_width (2.5.0)
54
-
55
- PLATFORMS
56
- arm64-darwin-23
57
- ruby
58
-
59
- DEPENDENCIES
60
- rake
61
- rbs-trace!
62
- rspec
63
- rubocop
64
- rubocop-rake
65
- rubocop-rspec
66
-
67
- BUNDLED WITH
68
- 2.5.17