Skip to content

Commit bbc5fe2

Browse files
authored
Merge branch 'master' into rubocop-on-rbs
2 parents 3795014 + 4192ea1 commit bbc5fe2

File tree

115 files changed

+3643
-1766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3643
-1766
lines changed

.github/workflows/dependabot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ env:
1111
jobs:
1212
dependabot:
1313
runs-on: ubuntu-latest
14-
if: ${{ github.actor == 'dependabot[bot]' }}
14+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
1515
steps:
16+
- name: Dependabot metadata
17+
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
18+
id: metadata
1619
- name: Checkout repository
1720
uses: actions/checkout@v4
1821
with:
@@ -21,6 +24,7 @@ jobs:
2124
run: git diff --exit-code ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} ${{ env.blocker_files }}
2225
- name: Enable auto-merge for Dependabot PRs
2326
run: gh pr merge --auto --merge "$PR_URL"
27+
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
2428
env:
2529
PR_URL: ${{github.event.pull_request.html_url}}
2630
GH_TOKEN: ${{secrets.DEPENDABOT_MERGE_GH_TOKEN}}

.github/workflows/ruby.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
bundler: none
4343
- name: Set working directory as safe
4444
run: git config --global --add safe.directory $(pwd)
45+
- name: Set up permission
46+
run: chmod -R o-w /opt/hostedtoolcache/Ruby
4547
- name: Install dependencies
4648
run: |
4749
sudo apt-get update

Gemfile.lock

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
rbs (3.5.1)
4+
rbs (3.6.0.dev.1)
55
logger
66

77
PATH
@@ -13,7 +13,7 @@ GEM
1313
remote: https://rubygems.org/
1414
specs:
1515
abbrev (0.1.2)
16-
activesupport (7.1.3.4)
16+
activesupport (7.1.4)
1717
base64
1818
bigdecimal
1919
concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -23,13 +23,13 @@ GEM
2323
minitest (>= 5.1)
2424
mutex_m
2525
tzinfo (~> 2.0)
26-
addressable (2.8.6)
27-
public_suffix (>= 2.0.2, < 6.0)
26+
addressable (2.8.7)
27+
public_suffix (>= 2.0.2, < 7.0)
2828
ast (2.4.2)
2929
base64 (0.2.0)
30-
benchmark-ips (2.13.0)
30+
benchmark-ips (2.14.0)
3131
bigdecimal (3.1.8)
32-
concurrent-ruby (1.3.3)
32+
concurrent-ruby (1.3.4)
3333
connection_pool (2.4.1)
3434
csv (3.3.0)
3535
dbm (1.1.0)
@@ -47,34 +47,34 @@ GEM
4747
i18n (1.14.5)
4848
concurrent-ruby (~> 1.0)
4949
json (2.7.2)
50-
json-schema (4.3.0)
51-
addressable (>= 2.8)
50+
json-schema (5.0.0)
51+
addressable (~> 2.8)
5252
language_server-protocol (3.17.0.3)
5353
listen (3.9.0)
5454
rb-fsevent (~> 0.10, >= 0.10.3)
5555
rb-inotify (~> 0.9, >= 0.9.10)
56-
logger (1.6.0)
56+
logger (1.6.1)
5757
marcel (1.0.4)
5858
memory_profiler (1.0.2)
59-
minitest (5.23.1)
59+
minitest (5.25.1)
6060
mutex_m (0.2.0)
6161
net-protocol (0.2.2)
6262
timeout
6363
net-smtp (0.5.0)
6464
net-protocol
6565
nkf (0.2.0)
66-
parallel (1.25.1)
67-
parser (3.3.3.0)
66+
parallel (1.26.3)
67+
parser (3.3.5.0)
6868
ast (~> 2.4.1)
6969
racc
7070
power_assert (2.0.3)
7171
psych (4.0.6)
7272
stringio
73-
public_suffix (5.1.0)
74-
raap (0.8.0)
73+
public_suffix (6.0.1)
74+
raap (1.0.0)
7575
rbs (~> 3.0)
7676
timeout (~> 0.4)
77-
racc (1.8.0)
77+
racc (1.8.1)
7878
rainbow (3.1.1)
7979
rake (13.2.1)
8080
rake-compiler (1.2.7)
@@ -85,33 +85,30 @@ GEM
8585
rdoc (6.6.3.1)
8686
psych (>= 4.0.0)
8787
regexp_parser (2.9.2)
88-
rexml (3.3.0)
89-
strscan
9088
rspec (3.13.0)
9189
rspec-core (~> 3.13.0)
9290
rspec-expectations (~> 3.13.0)
9391
rspec-mocks (~> 3.13.0)
94-
rspec-core (3.13.0)
92+
rspec-core (3.13.1)
9593
rspec-support (~> 3.13.0)
96-
rspec-expectations (3.13.1)
94+
rspec-expectations (3.13.3)
9795
diff-lcs (>= 1.2.0, < 2.0)
9896
rspec-support (~> 3.13.0)
9997
rspec-mocks (3.13.1)
10098
diff-lcs (>= 1.2.0, < 2.0)
10199
rspec-support (~> 3.13.0)
102100
rspec-support (3.13.1)
103-
rubocop (1.64.1)
101+
rubocop (1.66.1)
104102
json (~> 2.3)
105103
language_server-protocol (>= 3.17.0)
106104
parallel (~> 1.10)
107105
parser (>= 3.3.0.2)
108106
rainbow (>= 2.2.2, < 4.0)
109-
regexp_parser (>= 1.8, < 3.0)
110-
rexml (>= 3.2.5, < 4.0)
111-
rubocop-ast (>= 1.31.1, < 2.0)
107+
regexp_parser (>= 2.4, < 3.0)
108+
rubocop-ast (>= 1.32.2, < 2.0)
112109
ruby-progressbar (~> 1.7)
113110
unicode-display_width (>= 2.4.0, < 3.0)
114-
rubocop-ast (1.31.3)
111+
rubocop-ast (1.32.3)
115112
parser (>= 3.3.1.0)
116113
rubocop-on-rbs (0.6.0)
117114
rbs (~> 3.5)
@@ -188,4 +185,4 @@ DEPENDENCIES
188185
test-unit
189186

190187
BUNDLED WITH
191-
2.4.18
188+
2.5.16

core/array.rbs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ class Array[unchecked out Elem] < Object
10821082
# a.at(0) # => :foo
10831083
# a.at(2) # => 2
10841084
#
1085-
def at: (int index) -> Elem?
1085+
def at: %a{implicitly-returns-nil} (int index) -> Elem
10861086

10871087
# <!--
10881088
# rdoc-file=array.c
@@ -1378,7 +1378,7 @@ class Array[unchecked out Elem] < Object
13781378
#
13791379
# If `index` is too small (far from zero), returns nil.
13801380
#
1381-
def delete_at: (int index) -> Elem?
1381+
def delete_at: %a{implicitly-returns-nil} (int index) -> Elem
13821382

13831383
# <!--
13841384
# rdoc-file=array.c
@@ -1942,7 +1942,7 @@ class Array[unchecked out Elem] < Object
19421942
#
19431943
# Related: #last.
19441944
#
1945-
def first: () -> Elem?
1945+
def first: %a{implicitly-returns-nil} () -> Elem
19461946
| (int n) -> ::Array[Elem]
19471947

19481948
# <!--
@@ -2241,7 +2241,7 @@ class Array[unchecked out Elem] < Object
22412241
#
22422242
# Related: #first.
22432243
#
2244-
def last: () -> Elem?
2244+
def last: %a{implicitly-returns-nil} () -> Elem
22452245
| (int n) -> ::Array[Elem]
22462246

22472247
# <!--
@@ -2321,8 +2321,8 @@ class Array[unchecked out Elem] < Object
23212321
#
23222322
# ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
23232323
#
2324-
def max: () -> Elem?
2325-
| () { (Elem a, Elem b) -> ::Integer? } -> Elem?
2324+
def max: %a{implicitly-returns-nil} () -> Elem
2325+
| %a{implicitly-returns-nil} () { (Elem a, Elem b) -> ::Integer? } -> Elem
23262326
| (int n) -> ::Array[Elem]
23272327
| (int n) { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
23282328

@@ -3118,7 +3118,7 @@ class Array[unchecked out Elem] < Object
31183118
# a.sample(random: Random.new(1)) #=> 6
31193119
# a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
31203120
#
3121-
def sample: (?random: _Rand rng) -> Elem?
3121+
def sample: %a{implicitly-returns-nil} (?random: _Rand rng) -> Elem
31223122
| (int n, ?random: _Rand rng) -> ::Array[Elem]
31233123

31243124
# <!--
@@ -3197,7 +3197,7 @@ class Array[unchecked out Elem] < Object
31973197
#
31983198
# Related: #push, #pop, #unshift.
31993199
#
3200-
def shift: () -> Elem?
3200+
def shift: %a{implicitly-returns-nil} () -> Elem
32013201
| (int n) -> ::Array[Elem]
32023202

32033203
# <!--
@@ -3323,7 +3323,7 @@ class Array[unchecked out Elem] < Object
33233323
# # Raises TypeError (no implicit conversion of Symbol into Integer):
33243324
# a[:foo]
33253325
#
3326-
def slice: (int index) -> Elem?
3326+
def slice: %a{implicitly-returns-nil} (int index) -> Elem
33273327
| (int start, int length) -> ::Array[Elem]?
33283328
| (::Range[::Integer] range) -> ::Array[Elem]?
33293329

@@ -3393,7 +3393,7 @@ class Array[unchecked out Elem] < Object
33933393
# a.slice!(-2..2) # => ["bar", 2]
33943394
# a # => [:foo]
33953395
#
3396-
def slice!: (int index) -> Elem?
3396+
def slice!: %a{implicitly-returns-nil} (int index) -> Elem
33973397
| (int start, int length) -> ::Array[Elem]?
33983398
| (::Range[::Integer] range) -> ::Array[Elem]?
33993399

core/basic_object.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class BasicObject
163163
# k = Klass.new
164164
# k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
165165
#
166-
def __send__: (interned name, *untyped, **untyped) ?{ (*untyped, **untyped) -> untyped } -> untyped
166+
def __send__: (interned name, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
167167

168168
# <!-- rdoc-file=object.c -->
169169
# Equality --- At the Object level, #== returns `true` only if `obj` and `other`
@@ -248,7 +248,7 @@ class BasicObject
248248
# k = KlassWithSecret.new
249249
# k.instance_exec(5) {|x| @secret+x } #=> 104
250250
#
251-
def instance_exec: [U, V] (*V args) { (*V args) [self: self] -> U } -> U
251+
def instance_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
252252

253253
# <!--
254254
# rdoc-file=object.c
@@ -295,7 +295,7 @@ class BasicObject
295295
# r.mm #=> 2000
296296
# r.foo #=> NoMethodError
297297
#
298-
def method_missing: (Symbol, *untyped, **untyped) ?{ (*untyped, **untyped) -> untyped } -> untyped
298+
def method_missing: (Symbol, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
299299

300300
# <!--
301301
# rdoc-file=object.c

core/enumerable.rbs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
528528
#
529529
def entries: () -> ::Array[Elem]
530530

531+
def enum_for: (Symbol method, *untyped, **untyped) ?{ (?) -> Integer } -> Enumerator[untyped, untyped]
532+
| () ?{ () -> Integer } -> Enumerator[Elem, self]
533+
534+
%a{annotate:rdoc:skip}
535+
alias to_enum enum_for
536+
531537
# <!--
532538
# rdoc-file=enum.c
533539
# - select {|element| ... } -> array
@@ -1293,7 +1299,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
12931299
# With no block given, returns an Enumerator.
12941300
#
12951301
def reverse_each: () { (Elem arg0) -> untyped } -> void
1296-
| () -> ::Enumerator[Elem, void]
1302+
| () -> ::Enumerator[Elem]
12971303

12981304
# <!--
12991305
# rdoc-file=enum.c
@@ -1754,7 +1760,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
17541760
# # show pythagorean triples less than 100
17551761
# p pythagorean_triples.take_while { |*, z| z < 100 }.force
17561762
#
1757-
def lazy: () -> Enumerator::Lazy[Elem, void]
1763+
def lazy: () -> Enumerator::Lazy[Elem]
17581764

17591765
# <!--
17601766
# rdoc-file=enum.c
@@ -1840,7 +1846,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
18401846
# e = (1..3).chain([4, 5])
18411847
# e.to_a #=> [1, 2, 3, 4, 5]
18421848
#
1843-
def chain: (*self enumerables) -> ::Enumerator::Chain[Elem]
1849+
def chain: [Elem2] (*_Each[Elem2] enumerables) -> ::Enumerator::Chain[Elem | Elem2]
18441850

18451851
# <!--
18461852
# rdoc-file=enum.c
@@ -2086,8 +2092,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
20862092
# pp lines
20872093
# }
20882094
#
2089-
def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[ U, ::Array[Elem] ], void]
2090-
| () -> ::Enumerator[Elem, ::Enumerator[[ untyped, ::Array[Elem] ], void]]
2095+
def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[ U, ::Array[Elem] ]]
2096+
| () -> ::Enumerator[Elem, ::Enumerator[[ untyped, ::Array[Elem] ]]]
20912097

20922098
# <!--
20932099
# rdoc-file=enum.c
@@ -2136,7 +2142,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
21362142
# Enumerable#slice_when does the same, except splitting when the block returns
21372143
# `true` instead of `false`.
21382144
#
2139-
def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
2145+
def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem]]
21402146

21412147
# <!--
21422148
# rdoc-file=enum.c
@@ -2198,7 +2204,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
21982204
# Enumerable#chunk_while does the same, except splitting when the block returns
21992205
# `false` instead of `true`.
22002206
#
2201-
def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
2207+
def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem]]
22022208

22032209
# <!--
22042210
# rdoc-file=enum.c
@@ -2233,8 +2239,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
22332239
# p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }
22342240
# #=>["foo\n", "barbaz\n", "\n", "qux\n"]
22352241
#
2236-
def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
2237-
| () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
2242+
def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem]]
2243+
| () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem]]
22382244

22392245
# <!--
22402246
# rdoc-file=enum.c
@@ -2390,6 +2396,6 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
23902396
# }
23912397
# }
23922398
#
2393-
def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
2394-
| () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
2399+
def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem]]
2400+
| () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem]]
23952401
end

core/enumerator.rbs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@
127127
# puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
128128
# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
129129
#
130-
class Enumerator[unchecked out Elem, out Return] < Object
130+
class Enumerator[unchecked out Elem, out Return = void] < Object
131131
include Enumerable[Elem]
132132

133+
# A convenience interface for `each` with optional block
134+
#
135+
interface _Each[out E, out R]
136+
def each: () { (E) -> void } -> R
137+
| () -> Enumerator[E, R]
138+
end
139+
133140
# <!--
134141
# rdoc-file=enumerator.c
135142
# - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
@@ -560,7 +567,7 @@ end
560567
# # This returns an array of items like a normal enumerator does.
561568
# all_checked = active_items.select(&:checked)
562569
#
563-
class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
570+
class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
564571
# <!-- rdoc-file=enumerator.c -->
565572
# Expands `lazy` enumerator to an array. See Enumerable#to_a.
566573
#

core/enumerator/product.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%a{annotate:rdoc:skip}
2-
class Enumerator[unchecked out Elem, out Return]
2+
class Enumerator[unchecked out Elem, out Return = void]
33
# <!-- rdoc-file=enumerator.c -->
44
# Enumerator::Product generates a Cartesian product of any number of enumerable
55
# objects. Iterating over the product of enumerable objects is roughly

core/fiber.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class Fiber < Object
268268
# Explicitly using `storage: true` is currently experimental and may change in
269269
# the future.
270270
#
271-
def initialize: (?blocking: boolish, ?storage: true | Hash[interned, untyped] | nil) { (*untyped) -> void } -> void
271+
def initialize: (?blocking: boolish, ?storage: true | Hash[interned, untyped] | nil) { (?) -> void } -> void
272272

273273
# <!--
274274
# rdoc-file=cont.c

0 commit comments

Comments
 (0)