From 0e6d8c94e670c9230bba5e719ebb4393497941bc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Mar 2025 23:54:49 +0000 Subject: [PATCH] chore(internal): minor refactoring of utils --- Rakefile | 2 +- lib/openai/util.rb | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index cf2e280f..f8c899c1 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/]) xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --] -task(default: [:test]) +multitask(default: [:test]) multitask(:test) do rb = diff --git a/lib/openai/util.rb b/lib/openai/util.rb index a06aa76e..f19004c2 100644 --- a/lib/openai/util.rb +++ b/lib/openai/util.rb @@ -75,7 +75,7 @@ def primitive?(input) def coerce_boolean(input) case input.is_a?(String) ? input.downcase : input in Numeric - !input.zero? + input.nonzero? in "true" true in "false" @@ -165,14 +165,12 @@ class << self private def deep_merge_lr(lhs, rhs, concat: false) case [lhs, rhs, concat] in [Hash, Hash, _] - # rubocop:disable Style/YodaCondition - rhs_cleaned = rhs.reject { |_, val| OMIT == val } + rhs_cleaned = rhs.reject { _2 == OpenAI::Util::OMIT } lhs - .reject { |key, _| OMIT == rhs[key] } + .reject { |key, _| rhs[key] == OpenAI::Util::OMIT } .merge(rhs_cleaned) do |_, old_val, new_val| deep_merge_lr(old_val, new_val, concat: concat) end - # rubocop:enable Style/YodaCondition in [Array, Array, true] lhs.concat(rhs) else