rbs 3.4.0.pre.1 → 3.4.0
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/core/io.rbs +15 -5
- data/docs/gem.md +58 -0
- data/lib/rbs/test/errors.rb +6 -1
- data/lib/rbs/version.rb +1 -1
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3cadb8632c98b89ed21369dc36069d3f4070df6d289f4998398efa7d0265581
|
4
|
+
data.tar.gz: 985603ca882b4e3049661958d43607a42ad1e4672caf2393c0e3b276268725b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a75696df23d12ed0448fc3439abc4c80813df333586a66bccd16578a4d98701e8f736ef34e4f51b3983ee490604940b3798eceae0d28e33013af6be6ee211f23
|
7
|
+
data.tar.gz: 8a4edec0026f960dc9642b0fbb0398fde953ded13a8c347e9aabeb0cee904d242aeff76b76fde13b2e3b067a6767c3a12aee88c918d81bd996840ecb901d9b83
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 3.4.0 (2023-12-21)
|
6
|
+
|
7
|
+
### Signature updates
|
8
|
+
|
9
|
+
* minitest's lifecycle hooks ([#1694](https://github.com/ruby/rbs/pull/1694))
|
10
|
+
* `IO.popen`, `IO#read` ([#1693](https://github.com/ruby/rbs/pull/1693))
|
11
|
+
|
12
|
+
### Library changes
|
13
|
+
|
14
|
+
* Fix klass name if klass is singleton_class ([#1695](https://github.com/ruby/rbs/pull/1695))
|
15
|
+
|
16
|
+
### Miscellaneous
|
17
|
+
|
18
|
+
* Suppress warnings on testing ([#1691](https://github.com/ruby/rbs/pull/1691))
|
19
|
+
|
5
20
|
## 3.4.0.pre.1 (2023-12-19)
|
6
21
|
|
7
22
|
### Signature updates
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -56,7 +56,7 @@ end
|
|
56
56
|
task :validate => :compile do
|
57
57
|
require 'yaml'
|
58
58
|
|
59
|
-
sh "#{ruby} #{rbs} validate
|
59
|
+
sh "#{ruby} #{rbs} validate"
|
60
60
|
|
61
61
|
libs = FileList["stdlib/*"].map {|path| File.basename(path).to_s }
|
62
62
|
|
@@ -72,7 +72,7 @@ task :validate => :compile do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
libs.each do |lib|
|
75
|
-
sh "#{ruby} #{rbs} -r #{lib} validate
|
75
|
+
sh "#{ruby} #{rbs} -r #{lib} validate"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
data/core/io.rbs
CHANGED
@@ -1532,7 +1532,8 @@ class IO < Object
|
|
1532
1532
|
#
|
1533
1533
|
# Related: IO#write.
|
1534
1534
|
#
|
1535
|
-
def read: (?
|
1535
|
+
def read: (?nil, ?string outbuf) -> String
|
1536
|
+
| (int? length, ?string outbuf) -> String?
|
1536
1537
|
|
1537
1538
|
# <!--
|
1538
1539
|
# rdoc-file=io.rb
|
@@ -2533,10 +2534,19 @@ class IO < Object
|
|
2533
2534
|
#
|
2534
2535
|
# Raises exceptions that IO.pipe and Kernel.spawn raise.
|
2535
2536
|
#
|
2536
|
-
def self.popen: (string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2537
|
-
| (Hash[string, string?] env, string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2538
|
-
| [X] (string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2539
|
-
| [X] (Hash[string, string?] env, string cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2537
|
+
def self.popen: (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2538
|
+
| (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) -> instance
|
2539
|
+
| [X] (string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2540
|
+
| [X] (Hash[string, string?] env, string | cmd_array cmd, ?string | int mode, ?path: string?, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String, ?unsetenv_others: boolish, ?pgroup: true | Integer, ?umask: Integer, ?in: Kernel::redirect_fd, ?out: Kernel::redirect_fd, ?err: Kernel::redirect_fd, ?close_others: boolish, ?chdir: String) { (instance) -> X } -> X
|
2541
|
+
|
2542
|
+
# The command can be given as:
|
2543
|
+
#
|
2544
|
+
# * Array of string `["ruby", "-v"]`, or
|
2545
|
+
# * Array of string with the first element of array `[["ruby", "RUBY"], "-v"]`
|
2546
|
+
#
|
2547
|
+
# But RBS cannot define such a type. So this is simply a union of `string` or `[String, String]`.
|
2548
|
+
#
|
2549
|
+
type cmd_array = array[string | [String, String]]
|
2540
2550
|
|
2541
2551
|
# <!--
|
2542
2552
|
# rdoc-file=io.c
|
data/docs/gem.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Releasing a gem with RBS
|
2
|
+
|
3
|
+
You can release the RBS type definition of your gem included in the gem package. Just add your RBS files inside `/sig` directory, put them in your rubygem package, and release a new version. RBS gem will load the RBS files from your gem package automatically.
|
4
|
+
|
5
|
+
## `/sig` directory
|
6
|
+
|
7
|
+
RBS gem tries to load a type definition of a gem from gem package first. It checks if there is `/sig` directory in the gem package and loads `*.rbs` files from the directory. So, everything you have to do to make your type definition available are:
|
8
|
+
|
9
|
+
1. Add `/sig` directory in your gem package
|
10
|
+
2. Put your RBS files inside the directory
|
11
|
+
3. Make sure the RBS files are included in the gem package
|
12
|
+
|
13
|
+
### Hidden RBS files
|
14
|
+
|
15
|
+
If you have RBS files you don't want to export to the gem users, you can put the files under a directory that starts with `_``.
|
16
|
+
|
17
|
+
Assume you have three RBS files in your gem package:
|
18
|
+
|
19
|
+
* `/sig/foo.rbs`
|
20
|
+
* `/sig/bar/baz.rbs`
|
21
|
+
* `/sig/_private/internal.rbs`
|
22
|
+
|
23
|
+
`foo.rbs` and `baz.rbs` will be loaded from the gem package, but the `internal.rbs` will be skipped. This is only when you load RBS files of a *library*, for example through `-r` option given to `rbs` command. If you load RBS files as *source code*, for example through `-I` option given to `rbs` command, the hidden RBS files will be loaded too.
|
24
|
+
|
25
|
+
* `rbs -r your-gem` => Loading a library
|
26
|
+
* `rbs -I sig` => Loading RBS files as source code
|
27
|
+
|
28
|
+
### Adding `manifest.yaml`
|
29
|
+
|
30
|
+
`manifest.yaml` lets you declare dependencies to standard libraries. Here is an example, from [RBS gem](https://github.com/ruby/rbs/blob/6b3d0f976a50b3974d0bff26ea8fa9931053f38b/sig/manifest.yaml).
|
31
|
+
|
32
|
+
```yaml
|
33
|
+
dependencies:
|
34
|
+
- name: abbrev
|
35
|
+
- name: json
|
36
|
+
- name: logger
|
37
|
+
- name: optparse
|
38
|
+
- name: pathname
|
39
|
+
- name: rdoc
|
40
|
+
- name: tsort
|
41
|
+
```
|
42
|
+
|
43
|
+
Note that you don't have to write the dependencies that are included in your `.gemspec`. RBS will detect the dependencies between gems, declared in `.gemspec`. `manifest.yaml` is a material for undeclared dependencies, which usually is for standard libraries.
|
44
|
+
|
45
|
+
## Testing your type definition
|
46
|
+
|
47
|
+
If you develop your gem using a static type checker, like [Steep](https://github.com/soutaro/steep), your type definition will be (mostly) correct and reliable. If not, we strongly recommend adding extra tests focusing on the RBS type definitions.
|
48
|
+
|
49
|
+
`RBS::UnitTest` is a library to do that. `assert_send_type` is the most important assertion.
|
50
|
+
|
51
|
+
```rb
|
52
|
+
assert_send_type '(Regexp) { (String) -> String } -> String',
|
53
|
+
'hello', :gsub, /hello/, &proc { "foo" }
|
54
|
+
```
|
55
|
+
|
56
|
+
It calls `String#gsub` method and confirms if given arguments and the return value has correct types.
|
57
|
+
|
58
|
+
You can find examples under `test/stdlib` directory of [RBS repository](https://github.com/ruby/rbs/blob/6b3d0f976a50b3974d0bff26ea8fa9931053f38b/test/stdlib/String_test.rb).
|
data/lib/rbs/test/errors.rb
CHANGED
@@ -41,7 +41,12 @@ module RBS
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.to_string(error)
|
44
|
-
|
44
|
+
name = if error.klass.singleton_class?
|
45
|
+
inspect_(error.klass).sub(/\A#<Class:(.*)>\z/, '\1')
|
46
|
+
else
|
47
|
+
error.klass.name
|
48
|
+
end
|
49
|
+
method = "#{name}#{error.method_name}"
|
45
50
|
case error
|
46
51
|
when ArgumentTypeError
|
47
52
|
"[#{method}] ArgumentTypeError: expected #{format_param error.param} but given `#{inspect_(error.value)}`"
|
data/lib/rbs/version.rb
CHANGED
@@ -39,7 +39,7 @@ module Minitest::Test::LifecycleHooks
|
|
39
39
|
# include MyMinitestPlugin
|
40
40
|
# end
|
41
41
|
#
|
42
|
-
def before_setup: () ->
|
42
|
+
def before_setup: () -> void
|
43
43
|
|
44
44
|
# <!--
|
45
45
|
# rdoc-file=lib/minitest/test.rb
|
@@ -47,7 +47,7 @@ module Minitest::Test::LifecycleHooks
|
|
47
47
|
# -->
|
48
48
|
# Runs before every test. Use this to set up before each test run.
|
49
49
|
#
|
50
|
-
def setup: () ->
|
50
|
+
def setup: () -> void
|
51
51
|
|
52
52
|
# <!--
|
53
53
|
# rdoc-file=lib/minitest/test.rb
|
@@ -58,7 +58,7 @@ module Minitest::Test::LifecycleHooks
|
|
58
58
|
#
|
59
59
|
# See #before_setup for an example.
|
60
60
|
#
|
61
|
-
def after_setup: () ->
|
61
|
+
def after_setup: () -> void
|
62
62
|
|
63
63
|
# <!--
|
64
64
|
# rdoc-file=lib/minitest/test.rb
|
@@ -69,7 +69,7 @@ module Minitest::Test::LifecycleHooks
|
|
69
69
|
#
|
70
70
|
# See #before_setup for an example.
|
71
71
|
#
|
72
|
-
def before_teardown: () ->
|
72
|
+
def before_teardown: () -> void
|
73
73
|
|
74
74
|
# <!--
|
75
75
|
# rdoc-file=lib/minitest/test.rb
|
@@ -77,7 +77,7 @@ module Minitest::Test::LifecycleHooks
|
|
77
77
|
# -->
|
78
78
|
# Runs after every test. Use this to clean up after each test run.
|
79
79
|
#
|
80
|
-
def teardown: () ->
|
80
|
+
def teardown: () -> void
|
81
81
|
|
82
82
|
# <!--
|
83
83
|
# rdoc-file=lib/minitest/test.rb
|
@@ -88,5 +88,5 @@ module Minitest::Test::LifecycleHooks
|
|
88
88
|
#
|
89
89
|
# See #before_setup for an example.
|
90
90
|
#
|
91
|
-
def after_teardown: () ->
|
91
|
+
def after_teardown: () -> void
|
92
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.0
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abbrev
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- docs/CONTRIBUTING.md
|
135
135
|
- docs/collection.md
|
136
136
|
- docs/data_and_struct.md
|
137
|
+
- docs/gem.md
|
137
138
|
- docs/rbs_by_example.md
|
138
139
|
- docs/repo.md
|
139
140
|
- docs/sigs.md
|