rbs_goose 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -2
- data/.ruby-version +1 -1
- data/Gemfile +20 -13
- data/Gemfile.lock +69 -38
- data/README-ja.md +88 -0
- data/README.md +25 -22
- data/Rakefile +53 -8
- data/Steepfile +1 -3
- data/evaluations/01_rbs_goose/claude_haiku.log +1494 -0
- data/evaluations/01_rbs_goose/claude_opus.log +1439 -0
- data/evaluations/01_rbs_goose/claude_sonnet.log +1437 -0
- data/evaluations/01_rbs_goose/gpt-3-5-turbo.log +1241 -0
- data/evaluations/01_rbs_goose/gpt-4-turbo.log +1304 -0
- data/examples/fix_errors/Steepfile +6 -0
- data/examples/fix_errors/error_messages.txt +26 -0
- data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/refined/sig/email.rbs +1 -1
- data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/refined/sig/person.rbs +2 -2
- data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/refined/sig/phone.rbs +1 -1
- data/examples/fix_errors/sig/email.rbs +11 -0
- data/examples/fix_errors/sig/person.rbs +15 -0
- data/examples/fix_errors/sig/phone.rbs +15 -0
- data/examples/rbs_samples/lib/email.rb +16 -0
- data/examples/rbs_samples/lib/person.rb +23 -0
- data/examples/rbs_samples/lib/phone.rb +22 -0
- data/examples/rbs_samples/refined/sig/email.rbs +11 -0
- data/examples/rbs_samples/refined/sig/person.rbs +15 -0
- data/examples/rbs_samples/refined/sig/phone.rbs +15 -0
- data/examples/rbs_syntax/Steepfile +6 -0
- data/examples/rbs_syntax/lib/a.rb +53 -0
- data/examples/rbs_syntax/lib/list.rb +9 -0
- data/examples/rbs_syntax/lib/main.rb +17 -0
- data/examples/rbs_syntax/refined/sig/a.rbs +47 -0
- data/examples/rbs_syntax/refined/sig/list.rbs +7 -0
- data/examples/rbs_syntax/refined/sig/main.rbs +26 -0
- data/examples/rbs_syntax/sig/a.rbs +47 -0
- data/examples/rbs_syntax/sig/list.rbs +7 -0
- data/examples/rbs_syntax/sig/main.rbs +26 -0
- data/lib/rbs_goose/configuration.rb +93 -23
- data/lib/rbs_goose/io/example.rb +2 -2
- data/lib/rbs_goose/io/example_group.rb +16 -7
- data/lib/rbs_goose/io/target_group.rb +1 -1
- data/lib/rbs_goose/io/typed_ruby.rb +3 -3
- data/lib/rbs_goose/orthoses/fix_error.rb +26 -0
- data/lib/rbs_goose/orthoses/infer.rb +26 -0
- data/lib/rbs_goose/orthoses.rb +9 -0
- data/lib/rbs_goose/templates/base.rb +77 -0
- data/lib/rbs_goose/templates/fix_error_template.rb +43 -0
- data/lib/rbs_goose/templates/infer_template.rb +30 -0
- data/lib/rbs_goose/templates.rb +3 -1
- data/lib/rbs_goose/type_inferrer.rb +73 -2
- data/lib/rbs_goose/version.rb +1 -1
- data/lib/rbs_goose.rb +24 -4
- data/rbs_collection.lock.yaml +63 -47
- data/renovate.json +5 -0
- data/sig/rbs_goose/configuration.rbs +20 -12
- data/sig/rbs_goose/io/example.rbs +7 -7
- data/sig/rbs_goose/io/example_group.rbs +9 -7
- data/sig/rbs_goose/io/file.rbs +10 -10
- data/sig/rbs_goose/io/target_group.rbs +2 -2
- data/sig/rbs_goose/io/typed_ruby.rbs +7 -7
- data/sig/rbs_goose/io.rbs +1 -1
- data/sig/rbs_goose/orthoses/fix_error.rbs +11 -0
- data/sig/rbs_goose/orthoses/infer.rbs +11 -0
- data/sig/rbs_goose/orthoses.rbs +2 -0
- data/sig/rbs_goose/templates/base.rbs +18 -0
- data/sig/rbs_goose/templates/fix_error_template.rbs +6 -0
- data/sig/rbs_goose/templates/infer_template.rbs +6 -0
- data/sig/rbs_goose/templates.rbs +1 -1
- data/sig/rbs_goose/type_inferrer.rbs +9 -1
- data/sig/rbs_goose.rbs +18 -9
- metadata +137 -21
- data/README-EN-US.md +0 -85
- data/lib/rbs_goose/templates/default_template.rb +0 -49
- data/sig/rbs_goose/templates/default_template.rbs +0 -10
- /data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/lib/email.rb +0 -0
- /data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/lib/person.rb +0 -0
- /data/{lib/rbs_goose/examples/rbs_samples → examples/fix_errors}/lib/phone.rb +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/Steepfile +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/sig/email.rbs +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/sig/person.rbs +0 -0
- /data/{lib/rbs_goose/examples → examples}/rbs_samples/sig/phone.rbs +0 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# Type checking files:
|
2
|
+
|
3
|
+
..........................F.............................................F...............F
|
4
|
+
|
5
|
+
sig/phone.rbs:8:22: [error] Instance variable cannot have different type with parents: ::Integer <=> ::String
|
6
|
+
│ Diagnostic ID: RBS::InstanceVariableTypeError
|
7
|
+
│
|
8
|
+
└ attr_reader number: Integer
|
9
|
+
~~~~~~~
|
10
|
+
|
11
|
+
sig/person.rbs:8:24: [error] Instance variable cannot have different type with parents: ::Array[::String] <=> ::Array[(::Email | ::Phone)]
|
12
|
+
│ Diagnostic ID: RBS::InstanceVariableTypeError
|
13
|
+
│
|
14
|
+
└ attr_reader contacts: Array[String]
|
15
|
+
~~~~~~~~~~~~~
|
16
|
+
|
17
|
+
lib/person.rb:15:6: [error] Cannot allow method body have type `(::String | nil)` because declared as type `::String`
|
18
|
+
│ (::String | nil) <: ::String
|
19
|
+
│ nil <: ::String
|
20
|
+
│
|
21
|
+
│ Diagnostic ID: Ruby::MethodBodyTypeMismatch
|
22
|
+
│
|
23
|
+
└ def guess_country()
|
24
|
+
~~~~~~~~~~~~~
|
25
|
+
|
26
|
+
Detected 3 problems from 3 files
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class Person
|
2
2
|
@name: String
|
3
3
|
|
4
|
-
@contacts: Array[Email | Phone]
|
4
|
+
@contacts: Array[(Email | Phone)]
|
5
5
|
|
6
6
|
attr_reader name: String
|
7
7
|
|
8
|
-
attr_reader contacts: Array[Email | Phone]
|
8
|
+
attr_reader contacts: Array[(Email | Phone)]
|
9
9
|
|
10
10
|
def initialize: (name: String) -> void
|
11
11
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Person
|
2
|
+
@name: String
|
3
|
+
|
4
|
+
@contacts: Array[Email | Phone]
|
5
|
+
|
6
|
+
attr_reader name: String
|
7
|
+
|
8
|
+
attr_reader contacts: Array[String]
|
9
|
+
|
10
|
+
def initialize: (name: Integer) -> void
|
11
|
+
|
12
|
+
def name=: (String name) -> void
|
13
|
+
|
14
|
+
def guess_country: () -> String
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Phone
|
2
|
+
@country: String
|
3
|
+
|
4
|
+
@number: String
|
5
|
+
|
6
|
+
attr_reader country: String
|
7
|
+
|
8
|
+
attr_reader number: Integer
|
9
|
+
|
10
|
+
def initialize: (country: String, number: String) -> void
|
11
|
+
|
12
|
+
def ==: (Object other) -> (bool | nil)
|
13
|
+
|
14
|
+
def hash: () -> Integer
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Email
|
2
|
+
# @dynamic address
|
3
|
+
attr_reader :address
|
4
|
+
|
5
|
+
def initialize(address:)
|
6
|
+
@address = address
|
7
|
+
end
|
8
|
+
|
9
|
+
def ==(other)
|
10
|
+
other.is_a?(self.class) && other.address == address
|
11
|
+
end
|
12
|
+
|
13
|
+
def hash
|
14
|
+
self.class.hash ^ address.hash
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Person
|
2
|
+
# @dynamic name, contacts
|
3
|
+
attr_reader :name
|
4
|
+
attr_reader :contacts
|
5
|
+
|
6
|
+
def initialize(name:)
|
7
|
+
@name = name
|
8
|
+
@contacts = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def name=(name)
|
12
|
+
@name = name
|
13
|
+
end
|
14
|
+
|
15
|
+
def guess_country()
|
16
|
+
contacts.map do |contact|
|
17
|
+
case contact
|
18
|
+
when Phone
|
19
|
+
contact.country
|
20
|
+
end
|
21
|
+
end.compact.first
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Phone
|
2
|
+
# @dynamic country, number
|
3
|
+
attr_reader :country, :number
|
4
|
+
|
5
|
+
def initialize(country:, number:)
|
6
|
+
@country = country
|
7
|
+
@number = number
|
8
|
+
end
|
9
|
+
|
10
|
+
def ==(other)
|
11
|
+
if other.is_a?(Phone)
|
12
|
+
# @type var other: Phone
|
13
|
+
other.country == country && other.number == number
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def hash
|
20
|
+
self.class.hash ^ country.hash ^ number.hash
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Person
|
2
|
+
@name: String
|
3
|
+
|
4
|
+
@contacts: Array[(Email | Phone)]
|
5
|
+
|
6
|
+
attr_reader name: String
|
7
|
+
|
8
|
+
attr_reader contacts: Array[(Email | Phone)]
|
9
|
+
|
10
|
+
def initialize: (name: String) -> void
|
11
|
+
|
12
|
+
def name=: (String name) -> void
|
13
|
+
|
14
|
+
def guess_country: () -> (String | nil)
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Phone
|
2
|
+
@country: String
|
3
|
+
|
4
|
+
@number: String
|
5
|
+
|
6
|
+
attr_reader country: String
|
7
|
+
|
8
|
+
attr_reader number: String
|
9
|
+
|
10
|
+
def initialize: (country: String, number: String) -> void
|
11
|
+
|
12
|
+
def ==: (Object other) -> (bool | nil)
|
13
|
+
|
14
|
+
def hash: () -> Integer
|
15
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module M1
|
2
|
+
def m1(n)
|
3
|
+
"M1#{n}"
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module M2
|
8
|
+
def m2(s)
|
9
|
+
s.to_i
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
attr_reader :a, :b
|
15
|
+
|
16
|
+
def initialize(a, b = nil)
|
17
|
+
@a = a
|
18
|
+
@b = b
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class A < Base
|
23
|
+
include M1
|
24
|
+
extend M2
|
25
|
+
prepend Enumerable
|
26
|
+
|
27
|
+
attr_accessor :c
|
28
|
+
attr_reader :d, :f
|
29
|
+
|
30
|
+
def initialize(a, b = nil, c:, d:, f:)
|
31
|
+
super(a, b)
|
32
|
+
@c = c
|
33
|
+
@d = d
|
34
|
+
@f = f
|
35
|
+
end
|
36
|
+
|
37
|
+
def foo(foo)
|
38
|
+
n = foo[:i] || 0
|
39
|
+
s = "#{foo[:s]}#{n}"
|
40
|
+
r = @f.call(s)
|
41
|
+
FormattableString.new(r)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.bar
|
45
|
+
rand(2) == 0 ? "str" : 123
|
46
|
+
end
|
47
|
+
|
48
|
+
def each
|
49
|
+
yield 1
|
50
|
+
yield 2
|
51
|
+
yield 3
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
LITERAL_TYPES = [123, "str", :sym, true, false]
|
2
|
+
|
3
|
+
$GLOBAL_PROC = proc { |subject| "formatted: #{subject}" }
|
4
|
+
|
5
|
+
module Formattable
|
6
|
+
def format(formatter)
|
7
|
+
formatter.call(self.to_s)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class FormattableString < String
|
12
|
+
include Formattable
|
13
|
+
|
14
|
+
def format(formatter)
|
15
|
+
formatter.call(to_s)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module M1
|
2
|
+
def m1: (Integer) -> String
|
3
|
+
end
|
4
|
+
|
5
|
+
module M2
|
6
|
+
def m2: (String) -> Integer
|
7
|
+
end
|
8
|
+
|
9
|
+
class Base
|
10
|
+
@a: String
|
11
|
+
|
12
|
+
@b: Integer?
|
13
|
+
|
14
|
+
attr_reader a: String
|
15
|
+
|
16
|
+
attr_reader b: Integer?
|
17
|
+
|
18
|
+
def initialize: (String a, ?Integer? b) -> void
|
19
|
+
end
|
20
|
+
|
21
|
+
class A < Base
|
22
|
+
@c: bool
|
23
|
+
|
24
|
+
@d: [String, Integer]
|
25
|
+
|
26
|
+
@f: formatter
|
27
|
+
|
28
|
+
include M1
|
29
|
+
|
30
|
+
extend M2
|
31
|
+
|
32
|
+
prepend Enumerable[Integer]
|
33
|
+
|
34
|
+
attr_accessor c: bool
|
35
|
+
|
36
|
+
attr_reader d: [String, Integer]
|
37
|
+
|
38
|
+
attr_reader f: formatter
|
39
|
+
|
40
|
+
def initialize: (String a, ?Integer? b, c: bool c, d: [String, Integer], f: formatter) -> void
|
41
|
+
|
42
|
+
def foo: (foo) -> formattable_subject
|
43
|
+
|
44
|
+
def self.bar: () -> (Integer | String)
|
45
|
+
|
46
|
+
def each: () { (Integer) -> void } -> void
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
LITERAL_TYPES: [Integer, String, Symbol, (true | false)]
|
2
|
+
|
3
|
+
$GLOBAL_PROC: formatter
|
4
|
+
|
5
|
+
type subject = (String | Integer)
|
6
|
+
type formatter = ^(subject) [self: BasicObject] -> String
|
7
|
+
type formattable_subject = subject & _Formattable
|
8
|
+
|
9
|
+
type foo = {
|
10
|
+
s: String,
|
11
|
+
i: Integer?,
|
12
|
+
f: formatter
|
13
|
+
}
|
14
|
+
|
15
|
+
interface _Formattable
|
16
|
+
def format: (formatter formatter) -> String
|
17
|
+
end
|
18
|
+
|
19
|
+
module Formattable : _Formattable
|
20
|
+
end
|
21
|
+
|
22
|
+
class FormattableString < String
|
23
|
+
include Formattable
|
24
|
+
|
25
|
+
def format: (formatter formatter) -> String
|
26
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module M1
|
2
|
+
def m1: (untyped n) -> ::String
|
3
|
+
end
|
4
|
+
|
5
|
+
module M2
|
6
|
+
def m2: (untyped s) -> untyped
|
7
|
+
end
|
8
|
+
|
9
|
+
class Base
|
10
|
+
@a: untyped
|
11
|
+
|
12
|
+
@b: untyped
|
13
|
+
|
14
|
+
attr_reader a: untyped
|
15
|
+
|
16
|
+
attr_reader b: untyped
|
17
|
+
|
18
|
+
def initialize: (untyped a, ?untyped? b) -> void
|
19
|
+
end
|
20
|
+
|
21
|
+
class A < Base
|
22
|
+
@c: untyped
|
23
|
+
|
24
|
+
@d: untyped
|
25
|
+
|
26
|
+
@f: untyped
|
27
|
+
|
28
|
+
include M1
|
29
|
+
|
30
|
+
extend M2
|
31
|
+
|
32
|
+
prepend Enumerable
|
33
|
+
|
34
|
+
attr_accessor c: untyped
|
35
|
+
|
36
|
+
attr_reader d: untyped
|
37
|
+
|
38
|
+
attr_reader f: untyped
|
39
|
+
|
40
|
+
def initialize: (untyped a, ?untyped? b, c: untyped, d: untyped, f: untyped) -> void
|
41
|
+
|
42
|
+
def foo: (untyped foo) -> untyped
|
43
|
+
|
44
|
+
def self.bar: () -> ("str" | 123)
|
45
|
+
|
46
|
+
def each: () { (untyped) -> untyped } -> untyped
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
LITERAL_TYPES: [Integer, String, Symbol, true | false]
|
2
|
+
|
3
|
+
$GLOBAL_PROC: formatter
|
4
|
+
|
5
|
+
type subject = String | Integer
|
6
|
+
type formatter = ^(subject) [self: BasicObject] -> String
|
7
|
+
type formattable_subject = subject & _Formattable
|
8
|
+
|
9
|
+
type foo = {
|
10
|
+
s: String,
|
11
|
+
i: Integer?,
|
12
|
+
f: formatter
|
13
|
+
}
|
14
|
+
|
15
|
+
interface _Formattable
|
16
|
+
def format: (formatter formatter) -> String
|
17
|
+
end
|
18
|
+
|
19
|
+
module Formattable : _Formattable
|
20
|
+
end
|
21
|
+
|
22
|
+
class FormattableString < String
|
23
|
+
include Formattable
|
24
|
+
|
25
|
+
def format: (untyped formatter) -> untyped
|
26
|
+
end
|
@@ -1,40 +1,98 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'openai'
|
4
3
|
require 'langchain'
|
5
4
|
|
5
|
+
require 'forwardable'
|
6
|
+
|
6
7
|
module RbsGoose
|
7
8
|
class Configuration
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
LLMConfig = Struct.new(:client, :mode, keyword_init: true)
|
12
|
+
|
13
|
+
TemplateConfig = Struct.new(:instruction, :example_groups, :template_class, keyword_init: true) do
|
14
|
+
def build_template
|
15
|
+
template_class.new(instruction:, example_groups:)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(&)
|
20
|
+
self.infer_template = default_infer_template
|
21
|
+
self.fix_error_template = default_fix_error_template
|
22
|
+
instance_eval(&) if block_given?
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_accessor :llm, :infer_template, :fix_error_template
|
26
|
+
|
27
|
+
def use_open_ai( # rubocop:disable Metrics/MethodLength
|
28
|
+
open_ai_access_token, model_name: 'gpt-3.5-turbo-1106', mode: :chat,
|
29
|
+
llm_options: {}, default_options: {}
|
30
|
+
)
|
31
|
+
@llm = LLMConfig.new(
|
32
|
+
client: ::Langchain::LLM::OpenAI.new(
|
33
|
+
api_key: open_ai_access_token,
|
34
|
+
llm_options: { request_timeout: 600 }.merge(llm_options),
|
35
|
+
default_options: {
|
36
|
+
completion_model_name: model_name,
|
37
|
+
chat_completion_model_name: model_name
|
38
|
+
}.merge(default_options)
|
39
|
+
),
|
40
|
+
mode:
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def use_anthropic(access_token, model_name: 'claude-3-haiku-20240307', mode: :chat, default_options: {}) # rubocop:disable Metrics/MethodLength
|
45
|
+
@llm = LLMConfig.new(
|
46
|
+
client: ::Langchain::LLM::Anthropic.new(
|
47
|
+
api_key: access_token,
|
48
|
+
default_options: {
|
49
|
+
completion_model_name: model_name,
|
50
|
+
chat_completion_model_name: model_name,
|
51
|
+
max_tokens_to_sample: 4096
|
52
|
+
}.merge(default_options)
|
53
|
+
),
|
54
|
+
mode:
|
24
55
|
)
|
25
56
|
end
|
26
57
|
|
27
|
-
def
|
28
|
-
@
|
58
|
+
def use_ollama(url: 'http://localhost:11434', model_name: 'codegemma', mode: :complete, default_options: {}) # rubocop:disable Metrics/MethodLength
|
59
|
+
@llm = LLMConfig.new(
|
60
|
+
client: ::Langchain::LLM::Ollama.new(
|
61
|
+
url:,
|
62
|
+
default_options: {
|
63
|
+
temperature: 0.0,
|
64
|
+
completion_model_name: model_name,
|
65
|
+
chat_completion_model_name: model_name
|
66
|
+
}.merge(default_options)
|
67
|
+
),
|
68
|
+
mode:
|
69
|
+
)
|
29
70
|
end
|
30
71
|
|
72
|
+
def_delegator :llm, :client, :llm_client
|
73
|
+
def_delegator :llm, :mode, :llm_mode
|
74
|
+
def_delegator :infer_template, :instruction, :infer_instruction
|
75
|
+
def_delegator :infer_template, :example_groups, :infer_example_groups
|
76
|
+
|
31
77
|
private
|
32
78
|
|
33
|
-
def
|
34
|
-
|
79
|
+
def default_infer_template
|
80
|
+
TemplateConfig.new(
|
81
|
+
instruction: default_infer_instruction,
|
82
|
+
example_groups: default_infer_example_groups,
|
83
|
+
template_class: Templates::InferTemplate
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_fix_error_template
|
88
|
+
TemplateConfig.new(
|
89
|
+
instruction: default_fix_error_instruction,
|
90
|
+
example_groups: default_fix_error_example_groups,
|
91
|
+
template_class: Templates::FixErrorTemplate
|
92
|
+
)
|
35
93
|
end
|
36
94
|
|
37
|
-
def
|
95
|
+
def default_infer_instruction
|
38
96
|
<<~INSTRUCTION
|
39
97
|
Act as Ruby type inferrer.
|
40
98
|
When ruby source codes and RBS type signatures are given, refine each RBS type signatures. Each file should be split in markdown code format.
|
@@ -42,8 +100,20 @@ module RbsGoose
|
|
42
100
|
INSTRUCTION
|
43
101
|
end
|
44
102
|
|
45
|
-
def
|
103
|
+
def default_infer_example_groups
|
46
104
|
[RbsGoose::IO::ExampleGroup.default_examples[:rbs_samples]]
|
47
105
|
end
|
106
|
+
|
107
|
+
def default_fix_error_instruction
|
108
|
+
<<~INSTRUCTION
|
109
|
+
You are a highly skilled programmer.
|
110
|
+
Based on the following Ruby code, the RBS code that is a type definition, and the type checking error messages for them, modify the RBS code and output it.
|
111
|
+
All RBS files should be output, regardless of whether they have been modified or not.
|
112
|
+
INSTRUCTION
|
113
|
+
end
|
114
|
+
|
115
|
+
def default_fix_error_example_groups
|
116
|
+
[RbsGoose::IO::ExampleGroup.default_examples[:fix_errors]]
|
117
|
+
end
|
48
118
|
end
|
49
119
|
end
|
data/lib/rbs_goose/io/example.rb
CHANGED
@@ -6,7 +6,7 @@ module RbsGoose
|
|
6
6
|
class << self
|
7
7
|
def from_path(ruby_path:, rbs_path:, refined_rbs_dir:, base_path:)
|
8
8
|
Example.new(
|
9
|
-
typed_ruby: TypedRuby.from_path(ruby_path
|
9
|
+
typed_ruby: TypedRuby.from_path(ruby_path:, rbs_path:, base_path:),
|
10
10
|
refined_rbs: File.new(path: rbs_path, base_path: ::File.join(base_path, refined_rbs_dir))
|
11
11
|
)
|
12
12
|
end
|
@@ -18,7 +18,7 @@ module RbsGoose
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_h
|
21
|
-
{ typed_ruby
|
21
|
+
{ typed_ruby:, refined_rbs: }
|
22
22
|
end
|
23
23
|
|
24
24
|
attr_reader :typed_ruby, :refined_rbs
|