Skip to content

Commit 9cfaabd

Browse files
chore: more accurate type annotations for SDK internals (#83)
1 parent 899a7c0 commit 9cfaabd

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

rbi/lib/finch-api/type/array_of.rbi

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module FinchAPI
1111
abstract!
1212
final!
1313

14+
Elem = type_member(:out)
15+
1416
sig(:final) do
1517
params(
1618
type_info: T.any(
@@ -36,11 +38,7 @@ module FinchAPI
3638
# @api private
3739
sig(:final) do
3840
override
39-
.params(value: T.any(
40-
T::Enumerable[T.anything],
41-
T.anything
42-
),
43-
state: FinchAPI::Type::Converter::State)
41+
.params(value: T.any(T::Enumerable[Elem], T.anything), state: FinchAPI::Type::Converter::State)
4442
.returns(T.any(T::Array[T.anything], T.anything))
4543
end
4644
def coerce(value, state:)
@@ -49,14 +47,14 @@ module FinchAPI
4947
# @api private
5048
sig(:final) do
5149
override
52-
.params(value: T.any(T::Enumerable[T.anything], T.anything))
50+
.params(value: T.any(T::Enumerable[Elem], T.anything))
5351
.returns(T.any(T::Array[T.anything], T.anything))
5452
end
5553
def dump(value)
5654
end
5755

5856
# @api private
59-
sig(:final) { returns(T.anything) }
57+
sig(:final) { returns(Elem) }
6058
protected def item_type
6159
end
6260

rbi/lib/finch-api/type/hash_of.rbi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module FinchAPI
1111
abstract!
1212
final!
1313

14+
Elem = type_member(:out)
15+
1416
sig(:final) do
1517
params(
1618
type_info: T.any(
@@ -56,7 +58,7 @@ module FinchAPI
5658
end
5759

5860
# @api private
59-
sig(:final) { returns(T.anything) }
61+
sig(:final) { returns(Elem) }
6062
protected def item_type
6163
end
6264

sig/finch-api/type/array_of.rbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module FinchAPI
22
module Type
3-
class ArrayOf
3+
class ArrayOf[Elem]
44
include FinchAPI::Type::Converter
55

66
def self.[]: (
@@ -15,13 +15,13 @@ module FinchAPI
1515
def ==: (top other) -> bool
1616

1717
def coerce: (
18-
Enumerable[top] | top value,
18+
Enumerable[Elem] | top value,
1919
state: FinchAPI::Type::Converter::state
2020
) -> (::Array[top] | top)
2121

22-
def dump: (Enumerable[top] | top value) -> (::Array[top] | top)
22+
def dump: (Enumerable[Elem] | top value) -> (::Array[top] | top)
2323

24-
def item_type: -> top
24+
def item_type: -> Elem
2525

2626
def nilable?: -> bool
2727

sig/finch-api/type/hash_of.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module FinchAPI
22
module Type
3-
class HashOf
3+
class HashOf[Elem]
44
include FinchAPI::Type::Converter
55

66
def self.[]: (
@@ -21,7 +21,7 @@ module FinchAPI
2121

2222
def dump: (::Hash[top, top] | top value) -> (::Hash[Symbol, top] | top)
2323

24-
def item_type: -> top
24+
def item_type: -> Elem
2525

2626
def nilable?: -> bool
2727

0 commit comments

Comments
 (0)