Skip to content

Commit fd174e2

Browse files
committed
Ship RBS signatures for downstream consumers
Previously only sig/http.rbs was packaged, but it references `LLHttp::Parser` and `LLHttp::Delegate` (via HTTP::Response::Parser), which were defined only in the unshipped sig/deps.rbs. Consumers using `library "http"` in Steep hit `Cannot find type LLHttp::Delegate` errors when loading http.rbs. * Extract public LLHttp stubs from sig/deps.rbs into sig/llhttp.rbs. These belong in the shipped signatures because they appear in the public API surface. * Add sig/manifest.yaml declaring stdlib dependencies (base64, digest, forwardable, openssl, pathname, securerandom, singleton, tempfile, time, timeout, uri, zlib) so consumers don't need to re-list them. * Include sig/llhttp.rbs and sig/manifest.yaml in gemspec extras. * Keep sig/deps.rbs (Addressable, stdlib overrides, Numeric/IO supplements) as dev-only.
1 parent 10a257a commit fd174e2

8 files changed

Lines changed: 40 additions & 24 deletions

File tree

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ group :test do
3333
end
3434

3535
group :sig do
36-
gem "steep"
36+
gem "rbs", ">= 4"
37+
gem "steep", ">= 2"
3738
end
3839

3940
group :doc do

http.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
2626
spec.metadata["rubygems_mfa_required"] = "true"
2727

2828
spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
29-
extras = %w[LICENSE.txt README.md sig/http.rbs] << File.basename(__FILE__)
29+
extras = %w[LICENSE.txt README.md sig/http.rbs sig/llhttp.rbs sig/manifest.yaml] << File.basename(__FILE__)
3030

3131
ls.readlines("\x0", chomp: true).select do |f|
3232
f.start_with?("lib/") || extras.include?(f)

lib/http/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def check_premature_eof(eof)
254254
# @return [void]
255255
# @api private
256256
def connect_socket(req, options)
257-
@socket = options.timeout_class.new(**options.timeout_options) # steep:ignore
257+
@socket = options.timeout_class.new(**options.timeout_options)
258258
@socket.connect(options.socket_class, req.socket_host, req.socket_port, nodelay: options.nodelay)
259259

260260
send_proxy_connect_request(req)

lib/http/features/logging.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def logged_response_options(response)
158158
# @return [HTTP::Response::Body]
159159
# @api private
160160
def logged_body(body)
161-
formatter = (method(:format_binary) unless body.loggable?) # steep:ignore
161+
formatter = (method(:format_binary) unless body.loggable?)
162162
stream = BodyLogger.new(body.instance_variable_get(:@stream), logger, formatter: formatter) # steep:ignore
163163
Response::Body.new(stream, encoding: body.encoding)
164164
end

lib/http/uri/parsing.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ def normalize_host(host)
171171
# @return [Hash] URI components
172172
private_class_method def self.parse_with_addressable(uri_string)
173173
require_addressable
174-
parsed = Addressable::URI.parse(uri_string) # steep:ignore
174+
parsed = Addressable::URI.parse(uri_string)
175175
{ scheme: parsed.scheme, user: parsed.user, password: parsed.password,
176176
host: parsed.host, port: parsed.port, path: parsed.path,
177177
query: parsed.query, fragment: parsed.fragment }
178-
rescue Addressable::URI::InvalidURIError # steep:ignore
178+
rescue Addressable::URI::InvalidURIError
179179
raise InvalidError, "invalid URI: #{uri_string.inspect}"
180180
end
181181
end

sig/deps.rbs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,6 @@ module Zlib
7878
end
7979
end
8080

81-
module LLHttp
82-
class Error < StandardError
83-
end
84-
85-
class Parser
86-
def initialize: (untyped, ?type: Symbol) -> void
87-
def reset: () -> void
88-
def <<: (String) -> void
89-
def status_code: () -> Integer
90-
def http_major: () -> Integer
91-
def http_minor: () -> Integer
92-
end
93-
94-
class Delegate
95-
def initialize: () -> void
96-
end
97-
end
98-
9981
# Supplement: Numeric#to_i and #to_f are not in the stdlib RBS
10082
class Numeric
10183
def to_i: () -> Integer

sig/llhttp.rbs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Stubs for llhttp / llhttp-ffi, which do not ship their own RBS signatures.
2+
# Referenced by `HTTP::Response::Parser`, which is part of the public API.
3+
4+
module LLHttp
5+
class Error < StandardError
6+
end
7+
8+
class Parser
9+
def initialize: (untyped, ?type: Symbol) -> void
10+
def reset: () -> void
11+
def <<: (String) -> void
12+
def status_code: () -> Integer
13+
def http_major: () -> Integer
14+
def http_minor: () -> Integer
15+
end
16+
17+
class Delegate
18+
def initialize: () -> void
19+
end
20+
end

sig/manifest.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dependencies:
2+
- name: base64
3+
- name: digest
4+
- name: forwardable
5+
- name: openssl
6+
- name: pathname
7+
- name: securerandom
8+
- name: singleton
9+
- name: tempfile
10+
- name: time
11+
- name: timeout
12+
- name: uri
13+
- name: zlib

0 commit comments

Comments
 (0)