rbs 3.10.0.pre.2 → 3.10.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/c-check.yml +1 -1
  3. data/.github/workflows/comments.yml +2 -2
  4. data/.github/workflows/ruby.yml +7 -7
  5. data/CHANGELOG.md +49 -0
  6. data/core/array.rbs +56 -3
  7. data/core/complex.rbs +32 -21
  8. data/core/encoding.rbs +3 -7
  9. data/core/enumerable.rbs +1 -1
  10. data/core/enumerator.rbs +18 -1
  11. data/core/fiber.rbs +2 -1
  12. data/core/file.rbs +1 -1
  13. data/core/file_test.rbs +1 -1
  14. data/core/float.rbs +208 -21
  15. data/core/gc.rbs +4 -9
  16. data/core/hash.rbs +4 -4
  17. data/core/integer.rbs +78 -38
  18. data/core/io/buffer.rbs +18 -7
  19. data/core/io.rbs +8 -8
  20. data/core/kernel.rbs +8 -8
  21. data/core/module.rbs +17 -6
  22. data/core/numeric.rbs +8 -8
  23. data/core/object_space.rbs +13 -20
  24. data/core/pathname.rbs +2 -3
  25. data/core/ractor.rbs +4 -4
  26. data/core/range.rbs +1 -1
  27. data/core/rational.rbs +37 -24
  28. data/core/rbs/unnamed/argf.rbs +1 -1
  29. data/core/regexp.rbs +3 -3
  30. data/core/ruby.rbs +53 -0
  31. data/core/rubygems/version.rbs +2 -3
  32. data/core/set.rbs +86 -64
  33. data/core/string.rbs +275 -141
  34. data/core/thread.rbs +9 -9
  35. data/core/trace_point.rbs +7 -4
  36. data/lib/rbs/test/type_check.rb +1 -0
  37. data/lib/rbs/version.rb +1 -1
  38. data/lib/rdoc/discover.rb +1 -1
  39. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  40. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  41. data/stdlib/date/0/date.rbs +67 -59
  42. data/stdlib/date/0/date_time.rbs +1 -1
  43. data/stdlib/json/0/json.rbs +1 -0
  44. data/stdlib/objspace/0/objspace.rbs +1 -1
  45. data/stdlib/openssl/0/openssl.rbs +150 -80
  46. data/stdlib/psych/0/psych.rbs +3 -3
  47. data/stdlib/stringio/0/stringio.rbs +796 -37
  48. data/stdlib/strscan/0/string_scanner.rbs +1 -1
  49. data/stdlib/tempfile/0/tempfile.rbs +2 -2
  50. data/stdlib/time/0/time.rbs +1 -1
  51. data/stdlib/timeout/0/timeout.rbs +63 -7
  52. data/stdlib/uri/0/generic.rbs +1 -1
  53. metadata +3 -2
@@ -28,7 +28,7 @@
28
28
  # * `match_values_cleared?(scanner)`:
29
29
  # Returns whether the scanner's [match
30
30
  # values](rdoc-ref:StringScanner@Match+Values) are cleared.
31
- # See examples at [helper methods](doc/strscan/helper_methods.md).
31
+ # See examples at [helper methods](helper_methods.md).
32
32
  # ## The `StringScanner` Object
33
33
  # This code creates a `StringScanner` object
34
34
  # (we'll call it simply a *scanner*),
@@ -248,8 +248,8 @@ class Tempfile < File
248
248
  #
249
249
  # Implementation note:
250
250
  #
251
- # The keyword argument +anonymous=true+ is implemented using FILE_SHARE_DELETE
252
- # on Windows. O_TMPFILE is used on Linux.
251
+ # The keyword argument `anonymous=true` is implemented using `FILE_SHARE_DELETE`
252
+ # on Windows. `O_TMPFILE` is used on Linux.
253
253
  #
254
254
  # Related: Tempfile.new.
255
255
  #
@@ -10,7 +10,7 @@ class Time
10
10
 
11
11
  # <!--
12
12
  # rdoc-file=lib/time.rb
13
- # - zone_offset(zone, year=self.now.year)
13
+ # - zone_offset(zone, year=nil)
14
14
  # -->
15
15
  # Return the number of seconds the specified time zone differs from UTC.
16
16
  #
@@ -26,7 +26,7 @@ module Timeout
26
26
  # rdoc-file=lib/timeout.rb
27
27
  # - timeout(sec, klass = nil, message = nil) { |sec| ... }
28
28
  # -->
29
- # Perform an operation in a block, raising an error if it takes longer than
29
+ # Perform an operation in a block, raising an exception if it takes longer than
30
30
  # `sec` seconds to complete.
31
31
  #
32
32
  # `sec`
@@ -45,12 +45,20 @@ module Timeout
45
45
  #
46
46
  #
47
47
  # Returns the result of the block **if** the block completed before `sec`
48
- # seconds, otherwise throws an exception, based on the value of `klass`.
48
+ # seconds, otherwise raises an exception, based on the value of `klass`.
49
49
  #
50
- # The exception thrown to terminate the given block cannot be rescued inside the
51
- # block unless `klass` is given explicitly. However, the block can use ensure to
52
- # prevent the handling of the exception. For that reason, this method cannot be
53
- # relied on to enforce timeouts for untrusted blocks.
50
+ # The exception raised to terminate the given block is the given `klass`, or
51
+ # Timeout::ExitException if `klass` is not given. The reason for that behavior
52
+ # is that Timeout::Error inherits from RuntimeError and might be caught
53
+ # unexpectedly by `rescue`. Timeout::ExitException inherits from Exception so it
54
+ # will only be rescued by `rescue Exception`. Note that the
55
+ # Timeout::ExitException is translated to a Timeout::Error once it reaches the
56
+ # Timeout.timeout call, so outside that call it will be a Timeout::Error.
57
+ #
58
+ # In general, be aware that the code block may rescue the exception, and in such
59
+ # a case not respect the timeout. Also, the block can use `ensure` to prevent
60
+ # the handling of the exception. For those reasons, this method cannot be relied
61
+ # on to enforce timeouts for untrusted blocks.
54
62
  #
55
63
  # If a scheduler is defined, it will be used to handle the timeout by invoking
56
64
  # Scheduler#timeout_after.
@@ -59,11 +67,59 @@ module Timeout
59
67
  # Timeout` into your classes so they have a #timeout method, as well as a module
60
68
  # method, so you can call it directly as Timeout.timeout().
61
69
  #
70
+ # #### Ensuring the exception does not fire inside ensure blocks
71
+ #
72
+ # When using Timeout.timeout it can be desirable to ensure the timeout exception
73
+ # does not fire inside an `ensure` block. The simplest and best way to do so it
74
+ # to put the Timeout.timeout call inside the body of the begin/ensure/end:
75
+ #
76
+ # begin
77
+ # Timeout.timeout(sec) { some_long_operation }
78
+ # ensure
79
+ # cleanup # safe, cannot be interrupt by timeout
80
+ # end
81
+ #
82
+ # If that is not feasible, e.g. if there are `ensure` blocks inside
83
+ # `some_long_operation`, they need to not be interrupted by timeout, and it's
84
+ # not possible to move these ensure blocks outside, one can use
85
+ # Thread.handle_interrupt to delay the timeout exception like so:
86
+ #
87
+ # Thread.handle_interrupt(Timeout::Error => :never) {
88
+ # Timeout.timeout(sec, Timeout::Error) do
89
+ # setup # timeout cannot happen here, no matter how long it takes
90
+ # Thread.handle_interrupt(Timeout::Error => :immediate) {
91
+ # some_long_operation # timeout can happen here
92
+ # }
93
+ # ensure
94
+ # cleanup # timeout cannot happen here, no matter how long it takes
95
+ # end
96
+ # }
97
+ #
98
+ # An important thing to note is the need to pass an exception klass to
99
+ # Timeout.timeout, otherwise it does not work. Specifically, using
100
+ # +Thread.handle_interrupt(Timeout::ExitException => ...)+ is unsupported and
101
+ # causes subtle errors like raising the wrong exception outside the block, do
102
+ # not use that.
103
+ #
104
+ # Note that Thread.handle_interrupt is somewhat dangerous because if setup or
105
+ # cleanup hangs then the current thread will hang too and the timeout will never
106
+ # fire. Also note the block might run for longer than `sec` seconds: e.g.
107
+ # some_long_operation executes for `sec` seconds + whatever time cleanup takes.
108
+ #
109
+ # If you want the timeout to only happen on blocking operations one can use
110
+ # :on_blocking instead of :immediate. However, that means if the block uses no
111
+ # blocking operations after `sec` seconds, the block will not be interrupted.
112
+ # ----
113
+ # <!--
114
+ # rdoc-file=lib/timeout.rb
115
+ # - timeout(*args, &block)
116
+ # -->
117
+ #
62
118
  def self?.timeout: [T] (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> T } -> T
63
119
  end
64
120
 
65
121
  # <!-- rdoc-file=lib/timeout.rb -->
66
- # Internal error raised to when a timeout is triggered.
122
+ # Internal exception raised to when a timeout is triggered.
67
123
  #
68
124
  class Timeout::ExitException < Exception
69
125
  end
@@ -424,7 +424,7 @@ module URI
424
424
  #
425
425
  # uri = URI.parse("http://john:S3nsit1ve@my.example.com")
426
426
  # uri.user = "sam"
427
- # uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
427
+ # uri.to_s #=> "http://sam@my.example.com"
428
428
  #
429
429
  def user=: (String? user) -> String?
430
430
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0.pre.2
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
@@ -106,6 +106,7 @@ files:
106
106
  - core/rbs/unnamed/random.rbs
107
107
  - core/refinement.rbs
108
108
  - core/regexp.rbs
109
+ - core/ruby.rbs
109
110
  - core/ruby_vm.rbs
110
111
  - core/rubygems/basic_specification.rbs
111
112
  - core/rubygems/config_file.rbs
@@ -561,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
561
562
  - !ruby/object:Gem::Version
562
563
  version: '0'
563
564
  requirements: []
564
- rubygems_version: 4.0.1
565
+ rubygems_version: 4.0.2
565
566
  specification_version: 4
566
567
  summary: Type signature for Ruby.
567
568
  test_files: []