Skip to content

Commit c4c5609

Browse files
chore: more accurate type annotations for SDK internals (#71)
1 parent 1e16bab commit c4c5609

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

rbi/lib/openai/type/array_of.rbi

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

14+
Elem = type_member(:out)
15+
1416
sig(:final) do
1517
params(
1618
type_info: T.any(
@@ -36,7 +38,7 @@ module OpenAI
3638
# @api private
3739
sig(:final) do
3840
override
39-
.params(value: T.any(T::Enumerable[T.anything], T.anything), state: OpenAI::Type::Converter::State)
41+
.params(value: T.any(T::Enumerable[Elem], T.anything), state: OpenAI::Type::Converter::State)
4042
.returns(T.any(T::Array[T.anything], T.anything))
4143
end
4244
def coerce(value, state:)
@@ -45,14 +47,14 @@ module OpenAI
4547
# @api private
4648
sig(:final) do
4749
override
48-
.params(value: T.any(T::Enumerable[T.anything], T.anything))
50+
.params(value: T.any(T::Enumerable[Elem], T.anything))
4951
.returns(T.any(T::Array[T.anything], T.anything))
5052
end
5153
def dump(value)
5254
end
5355

5456
# @api private
55-
sig(:final) { returns(T.anything) }
57+
sig(:final) { returns(Elem) }
5658
protected def item_type
5759
end
5860

rbi/lib/openai/type/hash_of.rbi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ module OpenAI
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 OpenAI
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/openai/type/array_of.rbs

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

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

1717
def coerce: (
18-
Enumerable[top] | top value,
18+
Enumerable[Elem] | top value,
1919
state: OpenAI::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/openai/type/hash_of.rbs

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

66
def self.[]: (
@@ -21,7 +21,7 @@ module OpenAI
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)