From 386f3c46812b7f2e6b50a36e3614959282088db6 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Mon, 12 Jan 2026 10:15:05 +0000 Subject: [PATCH] add extra kwarg options for File#initialize and derivatives this adds the missing kwargs (known as "Open options" and "Encoding options" in the docs) signatures to the following methods, which implemented the same derivative signature: * File#initialize * File.open * Pathname#open --- core/file.rbs | 75 +++++++++++++++++++++++++++++++++++++++++++++-- core/pathname.rbs | 48 ++++++++++++++++++++++++++++-- 2 files changed, 118 insertions(+), 5 deletions(-) diff --git a/core/file.rbs b/core/file.rbs index 79e1c6ec1..9207a1194 100644 --- a/core/file.rbs +++ b/core/file.rbs @@ -847,7 +847,30 @@ class File < IO # * [Open Options](rdoc-ref:IO@Open+Options). # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options). # - def initialize: (path | int file_name, ?string | int mode, ?int perm) -> void + def initialize: ( + path | int file_name, + ?string | int mode, + ?int perm, + # open options + ?mode: Integer | String, + ?flags: Integer, + ?external_encoding: encoding, + ?internal_encoding: encoding, + ?encoding: encoding, + ?textmode: boolish, + ?binmode: boolish, + ?autoclose: boolish, + ?path: path, + # encoding options + ?invalid: :replace | nil, + ?undef: :replace | nil, + ?replace: String | nil, + ?fallback: Hash[string, string] | ^(String) -> string | Method | nil, + ?xml: :text | :attr | nil, + ?cr_newline: bool, + ?crlf_newline: bool, + ?universal_newline: bool + ) -> void # # See `File.open`. Opens the file for reading or writing. # - def open: (?string | int mode, ?int perm) -> File - | [T] (?string | int mode, ?int perm) { (File) -> T } -> T + def open: ( + ?string | int mode, + ?int perm, + # open options + ?mode: Integer | String, + ?flags: Integer, + ?external_encoding: encoding, + ?internal_encoding: encoding, + ?encoding: encoding, + ?textmode: boolish, + ?binmode: boolish, + ?autoclose: boolish, + ?path: path, + # encoding options + ?invalid: :replace | nil, + ?undef: :replace | nil, + ?replace: String | nil, + ?fallback: Hash[string, string] | ^(String) -> string | Method | nil, + ?xml: :text | :attr | nil, + ?cr_newline: bool, + ?crlf_newline: bool, + ?universal_newline: bool + ) -> File + | [T] ( + ?string | int mode, + ?int perm, + # open options + ?mode: Integer | String, + ?flags: Integer, + ?external_encoding: encoding, + ?internal_encoding: encoding, + ?encoding: encoding, + ?textmode: boolish, + ?binmode: boolish, + ?autoclose: boolish, + ?path: path, + # encoding options + ?invalid: :replace | nil, + ?undef: :replace | nil, + ?replace: String | nil, + ?fallback: Hash[string, string] | ^(String) -> string | Method | nil, + ?xml: :text | :attr | nil, + ?cr_newline: bool, + ?crlf_newline: bool, + ?universal_newline: bool + ) { (File) -> T } -> T #