Skip to content

Commit 8bbee83

Browse files
authored
Make Zlib::GzipWriter.new level and strategy parameters optional
The current signature requires all three positional arguments: def initialize: (_Writer io, Integer level, Integer strategy, **untyped opts) -> void However, the Ruby documentation and actual C implementation show that both level and strategy have default values (nil), making them optional: Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {}) The documentation examples also demonstrate calling with just io: File.open('hoge.gz', 'w') do |f| gz = Zlib::GzipWriter.new(f) gz.write 'jugemu jugemu gokou no surikire...' gz.close end This change updates the signature to allow 1-4 arguments by making level and strategy optional nilable parameters: def initialize: (_Writer io, ?Integer? level, ?Integer? strategy, **untyped opts) -> void This matches the actual Ruby behavior and resolves false positive type errors when calling GzipWriter.new with fewer than three arguments.
1 parent 9871d32 commit 8bbee83

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

stdlib/zlib/0/gzip_writer.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ module Zlib
162162
# `:external_encoding`, `:internal_encoding` and `:encoding` may be set as in
163163
# IO::new.
164164
#
165-
def initialize: (_Writer io, ?Integer level, ?Integer strategy, **untyped opts) -> void
165+
def initialize: (_Writer io, ?Integer? level, ?Integer? strategy, **untyped opts) -> void
166166
end
167167
end

0 commit comments

Comments
 (0)