From 7e86e10be8c0624233a2d27d1729fe6a533a0f5b Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 12 Sep 2024 02:32:30 +0900 Subject: [PATCH] stdlib: Update signature of CSV.read * It takes an IO object as `path` argument * It returns CSV::Table object when headers option given refs: * https://docs.ruby-lang.org/en/3.3/CSV.html#method-c-read * https://docs.ruby-lang.org/en/3.3/CSV.html#class-CSV-label-Option+headers --- stdlib/csv/0/csv.rbs | 3 ++- test/stdlib/CSV_test.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/stdlib/csv/0/csv.rbs b/stdlib/csv/0/csv.rbs index 63ede413e..59899dd12 100644 --- a/stdlib/csv/0/csv.rbs +++ b/stdlib/csv/0/csv.rbs @@ -2031,7 +2031,8 @@ class CSV < Object # File.write(path, string) # CSV.read(path, headers: true) # => # # - def self.read: (String path, ?::Hash[Symbol, untyped] options) -> ::Array[::Array[String?]] + def self.read: (String | IO path, headers: true | :first_row | Array[untyped] | String, **untyped options) -> ::CSV::Table[CSV::Row] + | (String | IO path, ?::Hash[Symbol, untyped] options) -> ::Array[::Array[String?]] #