rbs 3.2.0 → 3.3.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.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +1 -1
  3. data/.github/workflows/ruby.yml +7 -2
  4. data/.rubocop.yml +1 -1
  5. data/CHANGELOG.md +134 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +21 -15
  8. data/README.md +11 -2
  9. data/Rakefile +10 -7
  10. data/Steepfile +7 -7
  11. data/core/basic_object.rbs +7 -7
  12. data/core/binding.rbs +3 -3
  13. data/core/builtin.rbs +171 -5
  14. data/core/constants.rbs +17 -17
  15. data/core/dir.rbs +3 -3
  16. data/core/encoding.rbs +434 -628
  17. data/core/enumerator.rbs +37 -0
  18. data/core/exception.rbs +11 -11
  19. data/core/false_class.rbs +5 -11
  20. data/core/fiber.rbs +5 -5
  21. data/core/file_test.rbs +28 -26
  22. data/core/kernel.rbs +900 -21
  23. data/core/marshal.rbs +24 -14
  24. data/core/match_data.rbs +8 -8
  25. data/core/math.rbs +57 -53
  26. data/core/method.rbs +3 -1
  27. data/core/module.rbs +38 -36
  28. data/core/nil_class.rbs +7 -13
  29. data/core/object.rbs +3 -966
  30. data/core/process.rbs +3 -3
  31. data/core/ractor.rbs +2 -2
  32. data/core/rb_config.rbs +64 -43
  33. data/core/regexp.rbs +3 -3
  34. data/core/set.rbs +3 -2
  35. data/core/signal.rbs +10 -4
  36. data/core/struct.rbs +1 -1
  37. data/core/thread.rbs +7 -7
  38. data/core/thread_group.rbs +9 -9
  39. data/core/true_class.rbs +5 -11
  40. data/core/unbound_method.rbs +56 -7
  41. data/core/warning.rbs +33 -0
  42. data/docs/collection.md +56 -6
  43. data/docs/data_and_struct.md +57 -0
  44. data/docs/stdlib.md +61 -2
  45. data/docs/syntax.md +123 -2
  46. data/ext/rbs_extension/constants.c +73 -72
  47. data/ext/rbs_extension/lexer.c +624 -569
  48. data/ext/rbs_extension/lexer.h +1 -0
  49. data/ext/rbs_extension/lexer.re +1 -0
  50. data/ext/rbs_extension/lexstate.c +1 -0
  51. data/ext/rbs_extension/parser.c +6 -0
  52. data/goodcheck.yml +2 -2
  53. data/lib/rbs/annotate/formatter.rb +13 -3
  54. data/lib/rbs/annotate/rdoc_source.rb +10 -1
  55. data/lib/rbs/cli/colored_io.rb +48 -0
  56. data/lib/rbs/cli/diff.rb +80 -0
  57. data/lib/rbs/cli.rb +169 -17
  58. data/lib/rbs/collection/config/lockfile.rb +0 -25
  59. data/lib/rbs/collection/config/lockfile_generator.rb +0 -6
  60. data/lib/rbs/collection/installer.rb +1 -1
  61. data/lib/rbs/collection/sources/git.rb +6 -4
  62. data/lib/rbs/collection/sources/local.rb +7 -5
  63. data/lib/rbs/diff.rb +121 -0
  64. data/lib/rbs/environment.rb +7 -4
  65. data/lib/rbs/method_type.rb +23 -0
  66. data/lib/rbs/prototype/rb.rb +2 -9
  67. data/lib/rbs/prototype/rbi.rb +1 -1
  68. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  69. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  70. data/lib/rbs/prototype/runtime/value_object_generator.rb +275 -0
  71. data/lib/rbs/prototype/runtime.rb +233 -153
  72. data/lib/rbs/resolver/constant_resolver.rb +1 -1
  73. data/lib/rbs/sorter.rb +144 -117
  74. data/lib/rbs/test/guaranteed.rb +31 -0
  75. data/lib/rbs/test/type_check.rb +4 -4
  76. data/lib/rbs/test.rb +3 -0
  77. data/lib/rbs/types.rb +184 -3
  78. data/lib/rbs/version.rb +1 -1
  79. data/lib/rbs/writer.rb +4 -4
  80. data/lib/rbs.rb +1 -0
  81. data/rbs.gemspec +1 -0
  82. data/sig/annotate/formatter.rbs +2 -2
  83. data/sig/annotate/rdoc_annotater.rbs +1 -1
  84. data/sig/cli/colored_io.rbs +15 -0
  85. data/sig/cli/diff.rbs +21 -0
  86. data/sig/cli.rbs +2 -0
  87. data/sig/collection/config/lockfile.rbs +0 -6
  88. data/sig/diff.rbs +23 -0
  89. data/sig/errors.rbs +1 -5
  90. data/sig/method_types.rbs +6 -0
  91. data/sig/prototype/runtime.rbs +166 -0
  92. data/sig/rdoc/rbs.rbs +4 -0
  93. data/sig/shims/bundler.rbs +5 -0
  94. data/sig/sorter.rbs +23 -5
  95. data/sig/types.rbs +29 -0
  96. data/stdlib/benchmark/0/benchmark.rbs +1 -1
  97. data/stdlib/cgi/0/core.rbs +2 -2
  98. data/stdlib/did_you_mean/0/did_you_mean.rbs +2 -2
  99. data/stdlib/digest/0/digest.rbs +1 -1
  100. data/stdlib/fileutils/0/fileutils.rbs +1 -1
  101. data/stdlib/forwardable/0/forwardable.rbs +4 -4
  102. data/stdlib/io-console/0/io-console.rbs +1 -1
  103. data/stdlib/json/0/json.rbs +37 -0
  104. data/stdlib/logger/0/logger.rbs +2 -2
  105. data/stdlib/net-http/0/manifest.yaml +1 -1
  106. data/stdlib/net-http/0/net-http.rbs +16 -63
  107. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  108. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  109. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  110. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  111. data/stdlib/open-uri/0/manifest.yaml +3 -0
  112. data/stdlib/open-uri/0/open-uri.rbs +341 -0
  113. data/stdlib/openssl/0/openssl.rbs +1 -1
  114. data/stdlib/pp/0/manifest.yaml +2 -0
  115. data/stdlib/pp/0/pp.rbs +301 -0
  116. data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
  117. data/stdlib/psych/0/manifest.yaml +3 -0
  118. data/stdlib/psych/0/psych.rbs +391 -0
  119. data/stdlib/{yaml → psych}/0/store.rbs +2 -2
  120. data/stdlib/rdoc/0/code_object.rbs +55 -0
  121. data/stdlib/rdoc/0/comment.rbs +60 -0
  122. data/stdlib/rdoc/0/context.rbs +153 -0
  123. data/stdlib/rdoc/0/markup.rbs +119 -0
  124. data/stdlib/rdoc/0/parser.rbs +56 -0
  125. data/stdlib/rdoc/0/rdoc.rbs +0 -372
  126. data/stdlib/rdoc/0/ri.rbs +17 -0
  127. data/stdlib/rdoc/0/store.rbs +48 -0
  128. data/stdlib/rdoc/0/top_level.rbs +97 -0
  129. data/stdlib/socket/0/basic_socket.rbs +1 -1
  130. data/stdlib/socket/0/socket.rbs +1 -1
  131. data/stdlib/uri/0/common.rbs +1 -1
  132. data/stdlib/yaml/0/manifest.yaml +1 -2
  133. data/stdlib/yaml/0/yaml.rbs +1 -199
  134. metadata +49 -7
  135. data/sig/shims/pp.rbs +0 -3
  136. data/sig/shims.rbs +0 -47
@@ -0,0 +1,301 @@
1
+ # <!-- rdoc-file=lib/pp.rb -->
2
+ # A pretty-printer for Ruby objects.
3
+ #
4
+ # ## What PP Does
5
+ #
6
+ # Standard output by #p returns this:
7
+ # #<PP:0x81fedf0 @genspace=#<Proc:0x81feda0>, @group_queue=#<PrettyPrint::GroupQueue:0x81fed3c @queue=[[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], []]>, @buffer=[], @newline="\n", @group_stack=[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#<IO:0x8114ee4>>
8
+ #
9
+ # Pretty-printed output returns this:
10
+ # #<PP:0x81fedf0
11
+ # @buffer=[],
12
+ # @buffer_width=0,
13
+ # @genspace=#<Proc:0x81feda0>,
14
+ # @group_queue=
15
+ # #<PrettyPrint::GroupQueue:0x81fed3c
16
+ # @queue=
17
+ # [[#<PrettyPrint::Group:0x81fed78 @break=false, @breakables=[], @depth=0>],
18
+ # []]>,
19
+ # @group_stack=
20
+ # [#<PrettyPrint::Group:0x81fed78 @break=false, @breakables=[], @depth=0>],
21
+ # @indent=0,
22
+ # @maxwidth=79,
23
+ # @newline="\n",
24
+ # @output=#<IO:0x8114ee4>,
25
+ # @output_width=2>
26
+ #
27
+ # ## Usage
28
+ #
29
+ # pp(obj) #=> obj
30
+ # pp obj #=> obj
31
+ # pp(obj1, obj2, ...) #=> [obj1, obj2, ...]
32
+ # pp() #=> nil
33
+ #
34
+ # Output `obj(s)` to `$>` in pretty printed format.
35
+ #
36
+ # It returns `obj(s)`.
37
+ #
38
+ # ## Output Customization
39
+ #
40
+ # To define a customized pretty printing function for your classes, redefine
41
+ # method `#pretty_print(pp)` in the class.
42
+ #
43
+ # `#pretty_print` takes the `pp` argument, which is an instance of the PP class.
44
+ # The method uses #text, #breakable, #nest, #group and #pp to print the object.
45
+ #
46
+ # ## Pretty-Print JSON
47
+ #
48
+ # To pretty-print JSON refer to JSON#pretty_generate.
49
+ #
50
+ # ## Author
51
+ # Tanaka Akira <akr@fsij.org>
52
+ #
53
+ class PP < PrettyPrint
54
+ interface _PrettyPrint
55
+ def pretty_print: (untyped q) -> untyped
56
+
57
+ def pretty_print_cycle: (untyped q) -> untyped
58
+
59
+ def is_a?: (Module) -> bool
60
+ end
61
+
62
+ interface _LeftShift
63
+ def <<: (untyped obj) -> self
64
+ end
65
+
66
+ interface _PPMethodsRequired
67
+ def text: (String obj, ?Integer width) -> void
68
+
69
+ def breakable: (?String sep, ?Integer width) -> void
70
+
71
+ def group: (?Integer indent, ?String open_obj, ?String close_obj, ?Integer open_width, ?Integer close_width) { () -> untyped } -> void
72
+ end
73
+
74
+ module PPMethods : _PPMethodsRequired
75
+ # <!--
76
+ # rdoc-file=lib/pp.rb
77
+ # - guard_inspect_key() { || ... }
78
+ # -->
79
+ # Yields to a block and preserves the previous set of objects being printed.
80
+ #
81
+ def guard_inspect_key: () { () -> untyped } -> void
82
+
83
+ # <!--
84
+ # rdoc-file=lib/pp.rb
85
+ # - check_inspect_key(id)
86
+ # -->
87
+ # Check whether the object_id `id` is in the current buffer of objects to be
88
+ # pretty printed. Used to break cycles in chains of objects to be pretty
89
+ # printed.
90
+ #
91
+ def check_inspect_key: (_PrettyPrint id) -> bool
92
+
93
+ # <!--
94
+ # rdoc-file=lib/pp.rb
95
+ # - push_inspect_key(id)
96
+ # -->
97
+ # Adds the object_id `id` to the set of objects being pretty printed, so as to
98
+ # not repeat objects.
99
+ #
100
+ def push_inspect_key: (_PrettyPrint id) -> void
101
+
102
+ # <!--
103
+ # rdoc-file=lib/pp.rb
104
+ # - pop_inspect_key(id)
105
+ # -->
106
+ # Removes an object from the set of objects being pretty printed.
107
+ #
108
+ def pop_inspect_key: (_PrettyPrint id) -> void
109
+
110
+ # <!--
111
+ # rdoc-file=lib/pp.rb
112
+ # - pp(obj)
113
+ # -->
114
+ # Adds `obj` to the pretty printing buffer using Object#pretty_print or
115
+ # Object#pretty_print_cycle.
116
+ #
117
+ # Object#pretty_print_cycle is used when `obj` is already printed, a.k.a the
118
+ # object reference chain has a cycle.
119
+ #
120
+ def pp: (_PrettyPrint obj) -> untyped
121
+
122
+ # <!--
123
+ # rdoc-file=lib/pp.rb
124
+ # - object_group(obj) { || ... }
125
+ # -->
126
+ # A convenience method which is same as follows:
127
+ #
128
+ # group(1, '#<' + obj.class.name, '>') { ... }
129
+ #
130
+ def object_group: (untyped obj) { () -> untyped } -> Integer
131
+
132
+ # <!--
133
+ # rdoc-file=lib/pp.rb
134
+ # - object_address_group(obj, &block)
135
+ # -->
136
+ # A convenience method, like object_group, but also reformats the Object's
137
+ # object_id.
138
+ #
139
+ def object_address_group: (untyped obj) { () -> untyped } -> Integer
140
+
141
+ # <!--
142
+ # rdoc-file=lib/pp.rb
143
+ # - comma_breakable()
144
+ # -->
145
+ # A convenience method which is same as follows:
146
+ #
147
+ # text ','
148
+ # breakable
149
+ #
150
+ def comma_breakable: () -> void
151
+
152
+ # <!--
153
+ # rdoc-file=lib/pp.rb
154
+ # - seplist(list, sep=nil, iter_method=:each) { |element| ... }
155
+ # -->
156
+ # Adds a separated list. The list is separated by comma with breakable space, by
157
+ # default.
158
+ #
159
+ # #seplist iterates the `list` using `iter_method`. It yields each object to the
160
+ # block given for #seplist. The procedure `separator_proc` is called between
161
+ # each yields.
162
+ #
163
+ # If the iteration is zero times, `separator_proc` is not called at all.
164
+ #
165
+ # If `separator_proc` is nil or not given, +lambda { comma_breakable }+ is used.
166
+ # If `iter_method` is not given, :each is used.
167
+ #
168
+ # For example, following 3 code fragments has similar effect.
169
+ #
170
+ # q.seplist([1,2,3]) {|v| xxx v }
171
+ #
172
+ # q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v }
173
+ #
174
+ # xxx 1
175
+ # q.comma_breakable
176
+ # xxx 2
177
+ # q.comma_breakable
178
+ # xxx 3
179
+ #
180
+ def seplist: (untyped list, ?(^() -> void)? sep, ?interned iter_method) { (*untyped, **untyped) -> void } -> void
181
+
182
+ # <!--
183
+ # rdoc-file=lib/pp.rb
184
+ # - pp_object(obj)
185
+ # -->
186
+ # A present standard failsafe for pretty printing any given Object
187
+ #
188
+ def pp_object: (untyped obj) -> untyped
189
+
190
+ # <!--
191
+ # rdoc-file=lib/pp.rb
192
+ # - pp_hash(obj)
193
+ # -->
194
+ # A pretty print for a Hash
195
+ #
196
+ def pp_hash: (untyped obj) -> untyped
197
+ end
198
+ include PPMethods
199
+
200
+ class SingleLine < ::PrettyPrint::SingleLine
201
+ include PPMethods
202
+ end
203
+
204
+ module ObjectMixin : BasicObject
205
+ def pretty_print: (PP q) -> untyped
206
+
207
+ def pretty_print_cycle: (PP q) -> untyped
208
+
209
+ def pretty_print_instance_variables: () -> Array[Symbol]
210
+
211
+ def pretty_print_inspect: () -> untyped
212
+ end
213
+
214
+ # <!--
215
+ # rdoc-file=lib/pp.rb
216
+ # - width_for(out)
217
+ # -->
218
+ # Returns the usable width for `out`. As the width of `out`:
219
+ # 1. If `out` is assigned to a tty device, its width is used.
220
+ # 2. Otherwise, or it could not get the value, the `COLUMN` environment
221
+ # variable is assumed to be set to the width.
222
+ # 3. If `COLUMN` is not set to a non-zero number, 80 is assumed.
223
+ #
224
+ #
225
+ # And finally, returns the above width value - 1.
226
+ # * This -1 is for Windows command prompt, which moves the cursor to the next
227
+ # line if it reaches the last column.
228
+ #
229
+ def self.width_for: (untyped out) -> Integer
230
+
231
+ # <!--
232
+ # rdoc-file=lib/pp.rb
233
+ # - pp(obj, out=$>, width=width_for(out))
234
+ # -->
235
+ # Outputs `obj` to `out` in pretty printed format of `width` columns in width.
236
+ #
237
+ # If `out` is omitted, `$>` is assumed. If `width` is omitted, the width of
238
+ # `out` is assumed (see width_for).
239
+ #
240
+ # PP.pp returns `out`.
241
+ #
242
+ def self.pp: (_PrettyPrint obj, ?_LeftShift out, ?Integer width) -> untyped
243
+
244
+ # <!--
245
+ # rdoc-file=lib/pp.rb
246
+ # - singleline_pp(obj, out=$>)
247
+ # -->
248
+ # Outputs `obj` to `out` like PP.pp but with no indent and newline.
249
+ #
250
+ # PP.singleline_pp returns `out`.
251
+ #
252
+ def self.singleline_pp: (_PrettyPrint obj, ?_LeftShift out) -> untyped
253
+ def self.mcall: (untyped obj, Module mod, interned meth, *untyped args) ?{ (*untyped, **untyped) -> untyped } -> untyped
254
+
255
+ # <!--
256
+ # rdoc-file=lib/pp.rb
257
+ # - sharing_detection()
258
+ # -->
259
+ # Returns the sharing detection flag as a boolean value. It is false (nil) by
260
+ # default.
261
+ # ----
262
+ # <!--
263
+ # rdoc-file=lib/pp.rb
264
+ # - sharing_detection=(b)
265
+ # -->
266
+ # Sets the sharing detection flag to b.
267
+ #
268
+ attr_accessor self.sharing_detection: bool?
269
+ end
270
+
271
+ %a{annotate:rdoc:skip}
272
+ class RubyVM::AbstractSyntaxTree::Node
273
+ # <!--
274
+ # rdoc-file=lib/pp.rb
275
+ # - pretty_print_children(q, names = [])
276
+ # -->
277
+ #
278
+ def pretty_print_children: (PP q, ?Array[untyped] names) -> void
279
+ end
280
+
281
+ %a{annotate:rdoc:skip}
282
+ class Object
283
+ include PP::ObjectMixin
284
+ end
285
+
286
+ %a{annotate:rdoc:skip}
287
+ module Kernel
288
+ # <!--
289
+ # rdoc-file=lib/pp.rb
290
+ # - pretty_inspect()
291
+ # -->
292
+ # Returns a pretty printed object as a string.
293
+ #
294
+ # In order to use this method you must first require the PP module:
295
+ #
296
+ # require 'pp'
297
+ #
298
+ # See the PP module for more information.
299
+ #
300
+ def pretty_inspect: () -> String
301
+ end
@@ -1,5 +1,5 @@
1
1
  %a{annotate:rdoc:skip}
2
- module YAML
2
+ module Psych
3
3
  # <!-- rdoc-file=lib/yaml/dbm.rb -->
4
4
  # YAML + DBM = YDBM
5
5
  #
@@ -169,7 +169,7 @@ module YAML
169
169
  # object. Takes any object which implements the each_pair method, including Hash
170
170
  # and DBM objects.
171
171
  #
172
- def replace: (Hash[untyped, untyped] | DBM hsh) -> YAML::DBM
172
+ def replace: (Hash[untyped, untyped] | DBM hsh) -> Psych::DBM
173
173
 
174
174
  # <!--
175
175
  # rdoc-file=lib/yaml/dbm.rb
@@ -214,7 +214,7 @@ module YAML
214
214
  #
215
215
  # Returns `self`.
216
216
  #
217
- def update: (Hash[untyped, untyped]) -> YAML::DBM
217
+ def update: (Hash[untyped, untyped]) -> Psych::DBM
218
218
 
219
219
  # <!--
220
220
  # rdoc-file=lib/yaml/dbm.rb
@@ -0,0 +1,3 @@
1
+ dependencies:
2
+ - name: dbm
3
+ - name: pstore