From b84edaa939ab5e54359970f61a1b6a59210c4347 Mon Sep 17 00:00:00 2001 From: lineoffligbot <4628864+lineoffligbot@users.noreply.github.com> Date: Sun, 16 Aug 2026 16:43:42 +0200 Subject: [PATCH] Fix steep warnings introduced by rbs 4.1.3 CI does not commit Gemfile.lock, so the rbs upgrade from 4.0.3 to 4.1.3 landed unlocked and introduced eight steep warnings that fail `rake steep` on untouched main. Fix each by category: - rbs 4.1 now types two previously problematic calls correctly, turning their `# steep:ignore` comments into RedundantIgnoreComment warnings: drop them (Options.new, Options::Definitions#features=). - rbs 4.1 declares the block of `Enumerable#to_h` as returning `Hash::_Pair[K, V]`, an interface whose `to_ary` returns a tuple. Steep types an array-literal block body as `Array[...]`, never a tuple, so every `to_h { [k, v] }` now warns. Where an equally simple block-free form exists, use it: `Hash#invert` for Status::SYMBOL_CODES and a literal hash for PerOperation::KEYS. Headers#to_h, Headers#deconstruct_keys, and Options#to_hash keep their code with a targeted `# steep:ignore` instead: block-free rewrites of these trip Style/MapToHash or Style/ReduceToHash, and multi-line tuple assertions push Headers past Metrics/ClassLength. - Steep now types `&:size` in `CompositeIO#size` as a bare `::Proc`, which no longer matches `sum`'s optional block type. Keep the code with a targeted `# steep:ignore`, since the explicit-block form trips Style/SymbolProc. --- lib/http/form_data/composite_io.rb | 2 +- lib/http/headers.rb | 4 ++-- lib/http/options.rb | 4 ++-- lib/http/options/definitions.rb | 2 +- lib/http/response/status.rb | 2 +- lib/http/timeout/per_operation.rb | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/http/form_data/composite_io.rb b/lib/http/form_data/composite_io.rb index 33fa1f18..b9508f51 100644 --- a/lib/http/form_data/composite_io.rb +++ b/lib/http/form_data/composite_io.rb @@ -54,7 +54,7 @@ def read(length = nil, outbuf = nil) # @api public # @return [Integer] def size - @size ||= @ios.sum(&:size) + @size ||= @ios.sum(&:size) # steep:ignore end # Rewinds all IO objects and resets cursor diff --git a/lib/http/headers.rb b/lib/http/headers.rb index 892c28fe..af588f5a 100644 --- a/lib/http/headers.rb +++ b/lib/http/headers.rb @@ -184,7 +184,7 @@ def include?(name) # @return [Hash] # @api public def to_h - keys.to_h { |k| [k, self[k]] } + keys.to_h { |k| [k, self[k]] } # steep:ignore end # @!method to_hash # @see #to_h @@ -200,7 +200,7 @@ def to_h # @return [Hash{Symbol => Object}] # @api public def deconstruct_keys(keys) - hash = @pile.map { |_, k, _| k }.to_h { |k| [k.tr("A-Z-", "a-z_").to_sym, self[k]] } + hash = @pile.map { |_, k, _| k }.to_h { |k| [k.tr("A-Z-", "a-z_").to_sym, self[k]] } # steep:ignore keys ? hash.slice(*keys) : hash end diff --git a/lib/http/options.rb b/lib/http/options.rb index ff13359d..84cca6a4 100644 --- a/lib/http/options.rb +++ b/lib/http/options.rb @@ -61,7 +61,7 @@ class << self def new(options = nil, **kwargs) return options if options.is_a?(self) - super(**(options || kwargs)) # steep:ignore + super(**(options || kwargs)) end # Returns list of defined option names @@ -181,7 +181,7 @@ def merge(other) # @api public # @return [Hash] def to_hash - self.class.defined_options.to_h { |opt_name| [opt_name, public_send(opt_name)] } + self.class.defined_options.to_h { |opt_name| [opt_name, public_send(opt_name)] } # steep:ignore end # Duplicates the options object diff --git a/lib/http/options/definitions.rb b/lib/http/options/definitions.rb index ecea56a3..45ddfba2 100644 --- a/lib/http/options/definitions.rb +++ b/lib/http/options/definitions.rb @@ -45,7 +45,7 @@ def features=(features) unless (feature = self.class.available_features[name]) argument_error! "Unsupported feature: #{name}" end - feature.new(**opts_or_feature) # steep:ignore + feature.new(**opts_or_feature) end end end diff --git a/lib/http/response/status.rb b/lib/http/response/status.rb index 441102f5..3e1d7d48 100644 --- a/lib/http/response/status.rb +++ b/lib/http/response/status.rb @@ -66,7 +66,7 @@ def symbolize(str) # SYMBOL_CODES[:im_a_teapot] # => 418 # # @return [Hash Fixnum>] - SYMBOL_CODES = SYMBOLS.to_h { |k, v| [v, k] }.freeze + SYMBOL_CODES = SYMBOLS.invert.freeze # The numeric status code # diff --git a/lib/http/timeout/per_operation.rb b/lib/http/timeout/per_operation.rb index 5a5d3855..b7a6724d 100644 --- a/lib/http/timeout/per_operation.rb +++ b/lib/http/timeout/per_operation.rb @@ -9,7 +9,7 @@ module Timeout # Timeout handler with separate timeouts for connect, read, and write class PerOperation < Null # Mapping of shorthand option keys to their full forms - KEYS = %i[read write connect].to_h { |k| [k, :"#{k}_timeout"] }.freeze + KEYS = { read: :read_timeout, write: :write_timeout, connect: :connect_timeout }.freeze # Normalize and validate timeout options #