Skip to content

Commit 1ce65bd

Browse files
committed
Add positional hash parameter
1 parent fdba897 commit 1ce65bd

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

stdlib/net-http/0/net-http.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,8 +978,8 @@ module Net
978978
# Note: If `port` is `nil` and `opts[:use_ssl]` is a truthy value, the value
979979
# passed to `new` is Net::HTTP.https_default_port, not `port`.
980980
#
981-
def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, **untyped opt) -> Net::HTTP
982-
| [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, **untyped opt) { (Net::HTTP) -> T } -> T
981+
def self.start: (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]?, **untyped opt) -> Net::HTTP
982+
| [T] (String address, ?Integer? port, ?String | :ENV | nil p_addr, ?Integer? p_port, ?String? p_user, ?String? p_pass, ?Hash[Symbol, untyped]?, **untyped opt) { (Net::HTTP) -> T } -> T
983983

984984
# <!--
985985
# rdoc-file=lib/net/http.rb

test/stdlib/Net_HTTP_test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ def test_start
6161
Net::HTTP, :start, 'www.ruby-lang.org', 80 do |net_http| net_http.class end
6262
assert_send_type "(String, Integer, use_ssl: bool) { (Net::HTTP) -> untyped } -> untyped",
6363
Net::HTTP, :start, 'www.ruby-lang.org', 443, use_ssl: true do |net_http| net_http.class end
64-
end
64+
65+
assert_send_type(
66+
"(String, Integer, nil, nil, nil, nil, Hash[Symbol, untyped]) { (Net::HTTP) -> Class } -> Class",
67+
Net::HTTP, :start, 'www.ruby-lang.org', 443, nil, nil, nil, nil, { use_ssl: true }, &->(net_http) { net_http.class }
68+
)
69+
end
6570
end
6671

6772
class NetInstanceTest < Test::Unit::TestCase

test/typecheck/net_http/Steepfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
D = Steep::Diagnostic
2+
3+
target :test do
4+
signature "."
5+
check "."
6+
library "net-http"
7+
configure_code_diagnostics(D::Ruby.all_error)
8+
end

test/typecheck/net_http/start.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Passing keyword args is allowed.
2+
Net::HTTP.start('example.com', open_timeout: 10)
3+
4+
# Passing a hash object is also allowed, but it needs the predecessor arguments.
5+
Net::HTTP.start('example.com', 443, nil, nil, nil, nil, { open_timeout: 10, read_timeout: 10 })

0 commit comments

Comments
 (0)