Skip to content

Commit 8ec00ad

Browse files
chore: refine Yard and Sorbet types and ensure linting is turned on for examples
1 parent 1decdd2 commit 8ec00ad

File tree

9 files changed

+62
-82
lines changed

9 files changed

+62
-82
lines changed

Rakefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require "rake/clean"
99
require "rubocop/rake_task"
1010

1111
tapioca = "sorbet/tapioca"
12+
examples = "examples"
1213
ignore_file = ".ignore"
1314

1415
CLEAN.push(*%w[.idea/ .ruby-lsp/ .yardoc/ doc/], *FileList["*.gem"], ignore_file)
@@ -39,7 +40,7 @@ locale = {"LC_ALL" => "C.UTF-8"}
3940

4041
desc("Lint `*.rb(i)`")
4142
multitask(:"lint:rubocop") do
42-
find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
43+
find = %w[find ./lib ./test ./rbi ./examples -type f -and ( -name *.rb -or -name *.rbi ) -print0]
4344

4445
rubocop = %w[rubocop]
4546
rubocop += %w[--format github] if ENV.key?("CI")
@@ -54,7 +55,7 @@ end
5455
desc("Format `*.rb`")
5556
multitask(:"format:rb") do
5657
# while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support
57-
find = %w[find ./lib ./test -type f -and -name *.rb -print0]
58+
find = %w[find ./lib ./test ./examples -type f -and -name *.rb -print0]
5859
fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --]
5960
sh("#{find.shelljoin} | #{fmt.shelljoin}")
6061
end
@@ -117,12 +118,14 @@ multitask(:"typecheck:steep") do
117118
sh(*%w[steep check])
118119
end
119120

121+
directory(examples)
122+
120123
desc("Typecheck `*.rbi`")
121-
multitask(:"typecheck:sorbet") do
122-
sh(*%w[srb typecheck])
124+
multitask("typecheck:sorbet": examples) do
125+
sh(*%w[srb typecheck --dir], examples)
123126
end
124127

125-
file(tapioca) do
128+
directory(tapioca) do
126129
sh(*%w[tapioca init])
127130
end
128131

lib/orb/internal.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ module Internal
1313
define_sorbet_constant!(:AnyHash) do
1414
T.type_alias { T::Hash[Symbol, T.anything] }
1515
end
16+
define_sorbet_constant!(:FileInput) do
17+
T.type_alias { T.any(Pathname, StringIO, IO, String, Orb::FilePart) }
18+
end
1619
end
1720
end

rbi/orb/internal.rbi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ module Orb
88
# this alias might be refined in the future.
99
AnyHash = T.type_alias { T::Hash[Symbol, T.anything] }
1010

11+
FileInput =
12+
T.type_alias { T.any(Pathname, StringIO, IO, String, Orb::FilePart) }
13+
1114
OMIT = T.let(Object.new.freeze, T.anything)
1215
end
1316
end

rbi/orb/models/subscription_price_intervals_params.rbi

Lines changed: 26 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ module Orb
146146

147147
# The start date of the price interval. This is the date that the price will start
148148
# billing on the subscription.
149-
sig do
150-
returns(
151-
Orb::SubscriptionPriceIntervalsParams::Add::StartDate::Variants
152-
)
153-
end
149+
sig { returns(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)) }
154150
attr_accessor :start_date
155151

156152
# The definition of a new allocation price to create and add to the subscription.
@@ -193,9 +189,7 @@ module Orb
193189
# billing on the subscription.
194190
sig do
195191
returns(
196-
T.nilable(
197-
Orb::SubscriptionPriceIntervalsParams::Add::EndDate::Variants
198-
)
192+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
199193
)
200194
end
201195
attr_accessor :end_date
@@ -287,8 +281,7 @@ module Orb
287281

288282
sig do
289283
params(
290-
start_date:
291-
Orb::SubscriptionPriceIntervalsParams::Add::StartDate::Variants,
284+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol),
292285
allocation_price:
293286
T.nilable(
294287
Orb::SubscriptionPriceIntervalsParams::Add::AllocationPrice::OrHash
@@ -304,9 +297,7 @@ module Orb
304297
]
305298
),
306299
end_date:
307-
T.nilable(
308-
Orb::SubscriptionPriceIntervalsParams::Add::EndDate::Variants
309-
),
300+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)),
310301
external_price_id: T.nilable(String),
311302
filter: T.nilable(String),
312303
fixed_fee_quantity_transitions:
@@ -397,8 +388,7 @@ module Orb
397388
sig do
398389
override.returns(
399390
{
400-
start_date:
401-
Orb::SubscriptionPriceIntervalsParams::Add::StartDate::Variants,
391+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol),
402392
allocation_price:
403393
T.nilable(
404394
Orb::SubscriptionPriceIntervalsParams::Add::AllocationPrice
@@ -414,9 +404,7 @@ module Orb
414404
]
415405
),
416406
end_date:
417-
T.nilable(
418-
Orb::SubscriptionPriceIntervalsParams::Add::EndDate::Variants
419-
),
407+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)),
420408
external_price_id: T.nilable(String),
421409
filter: T.nilable(String),
422410
fixed_fee_quantity_transitions:
@@ -13896,11 +13884,7 @@ module Orb
1389613884
# will start affecting prices on the subscription. The adjustment will apply to
1389713885
# invoice dates that overlap with this `start_date`. This `start_date` is treated
1389813886
# as inclusive for in-advance prices, and exclusive for in-arrears prices.
13899-
sig do
13900-
returns(
13901-
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::StartDate::Variants
13902-
)
13903-
end
13887+
sig { returns(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)) }
1390413888
attr_accessor :start_date
1390513889

1390613890
# The end date of the adjustment interval. This is the date that the adjustment
@@ -13909,9 +13893,7 @@ module Orb
1390913893
# exclusive for in-advance prices, and inclusive for in-arrears prices.
1391013894
sig do
1391113895
returns(
13912-
T.nilable(
13913-
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::EndDate::Variants
13914-
)
13896+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1391513897
)
1391613898
end
1391713899
attr_accessor :end_date
@@ -13926,12 +13908,9 @@ module Orb
1392613908
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::Adjustment::Minimum::OrHash,
1392713909
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::Adjustment::Maximum::OrHash
1392813910
),
13929-
start_date:
13930-
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::StartDate::Variants,
13911+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol),
1393113912
end_date:
13932-
T.nilable(
13933-
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::EndDate::Variants
13934-
)
13913+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1393513914
).returns(T.attached_class)
1393613915
end
1393713916
def self.new(
@@ -13961,12 +13940,9 @@ module Orb
1396113940
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::Adjustment::Minimum,
1396213941
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::Adjustment::Maximum
1396313942
),
13964-
start_date:
13965-
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::StartDate::Variants,
13943+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol),
1396613944
end_date:
13967-
T.nilable(
13968-
Orb::SubscriptionPriceIntervalsParams::AddAdjustment::EndDate::Variants
13969-
)
13945+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1397013946
}
1397113947
)
1397213948
end
@@ -14377,9 +14353,7 @@ module Orb
1437714353
# will not be updated.
1437814354
sig do
1437914355
returns(
14380-
T.nilable(
14381-
Orb::SubscriptionPriceIntervalsParams::Edit::EndDate::Variants
14382-
)
14356+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1438314357
)
1438414358
end
1438514359
attr_accessor :end_date
@@ -14409,17 +14383,14 @@ module Orb
1440914383
# will not be updated.
1441014384
sig do
1441114385
returns(
14412-
T.nilable(
14413-
Orb::SubscriptionPriceIntervalsParams::Edit::StartDate::Variants
14414-
)
14386+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1441514387
)
1441614388
end
1441714389
attr_reader :start_date
1441814390

1441914391
sig do
1442014392
params(
14421-
start_date:
14422-
Orb::SubscriptionPriceIntervalsParams::Edit::StartDate::Variants
14393+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)
1442314394
).void
1442414395
end
1442514396
attr_writer :start_date
@@ -14438,18 +14409,15 @@ module Orb
1443814409
price_interval_id: String,
1443914410
billing_cycle_day: T.nilable(Integer),
1444014411
end_date:
14441-
T.nilable(
14442-
Orb::SubscriptionPriceIntervalsParams::Edit::EndDate::Variants
14443-
),
14412+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)),
1444414413
filter: T.nilable(String),
1444514414
fixed_fee_quantity_transitions:
1444614415
T.nilable(
1444714416
T::Array[
1444814417
Orb::SubscriptionPriceIntervalsParams::Edit::FixedFeeQuantityTransition::OrHash
1444914418
]
1445014419
),
14451-
start_date:
14452-
Orb::SubscriptionPriceIntervalsParams::Edit::StartDate::Variants,
14420+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol),
1445314421
usage_customer_ids: T.nilable(T::Array[String])
1445414422
).returns(T.attached_class)
1445514423
end
@@ -14491,18 +14459,15 @@ module Orb
1449114459
price_interval_id: String,
1449214460
billing_cycle_day: T.nilable(Integer),
1449314461
end_date:
14494-
T.nilable(
14495-
Orb::SubscriptionPriceIntervalsParams::Edit::EndDate::Variants
14496-
),
14462+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)),
1449714463
filter: T.nilable(String),
1449814464
fixed_fee_quantity_transitions:
1449914465
T.nilable(
1450014466
T::Array[
1450114467
Orb::SubscriptionPriceIntervalsParams::Edit::FixedFeeQuantityTransition
1450214468
]
1450314469
),
14504-
start_date:
14505-
Orb::SubscriptionPriceIntervalsParams::Edit::StartDate::Variants,
14470+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol),
1450614471
usage_customer_ids: T.nilable(T::Array[String])
1450714472
}
1450814473
)
@@ -14605,9 +14570,7 @@ module Orb
1460514570
# date will not be updated.
1460614571
sig do
1460714572
returns(
14608-
T.nilable(
14609-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::EndDate::Variants
14610-
)
14573+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1461114574
)
1461214575
end
1461314576
attr_accessor :end_date
@@ -14616,17 +14579,14 @@ module Orb
1461614579
# date will not be updated.
1461714580
sig do
1461814581
returns(
14619-
T.nilable(
14620-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::StartDate::Variants
14621-
)
14582+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol))
1462214583
)
1462314584
end
1462414585
attr_reader :start_date
1462514586

1462614587
sig do
1462714588
params(
14628-
start_date:
14629-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::StartDate::Variants
14589+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)
1463014590
).void
1463114591
end
1463214592
attr_writer :start_date
@@ -14635,11 +14595,8 @@ module Orb
1463514595
params(
1463614596
adjustment_interval_id: String,
1463714597
end_date:
14638-
T.nilable(
14639-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::EndDate::Variants
14640-
),
14641-
start_date:
14642-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::StartDate::Variants
14598+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)),
14599+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)
1464314600
).returns(T.attached_class)
1464414601
end
1464514602
def self.new(
@@ -14659,11 +14616,8 @@ module Orb
1465914616
{
1466014617
adjustment_interval_id: String,
1466114618
end_date:
14662-
T.nilable(
14663-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::EndDate::Variants
14664-
),
14665-
start_date:
14666-
Orb::SubscriptionPriceIntervalsParams::EditAdjustment::StartDate::Variants
14619+
T.nilable(T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)),
14620+
start_date: T.any(Time, Orb::BillingCycleRelativeDate::OrSymbol)
1466714621
}
1466814622
)
1466914623
end

rbi/orb/models/subscription_update_trial_params.rbi

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ module Orb
1414
# The new date that the trial should end, or the literal string `immediate` to end
1515
# the trial immediately.
1616
sig do
17-
returns(Orb::SubscriptionUpdateTrialParams::TrialEndDate::Variants)
17+
returns(
18+
T.any(
19+
Time,
20+
Orb::SubscriptionUpdateTrialParams::TrialEndDate::OrSymbol
21+
)
22+
)
1823
end
1924
attr_accessor :trial_end_date
2025

@@ -29,7 +34,10 @@ module Orb
2934
sig do
3035
params(
3136
trial_end_date:
32-
Orb::SubscriptionUpdateTrialParams::TrialEndDate::Variants,
37+
T.any(
38+
Time,
39+
Orb::SubscriptionUpdateTrialParams::TrialEndDate::OrSymbol
40+
),
3341
shift: T::Boolean,
3442
request_options: Orb::RequestOptions::OrHash
3543
).returns(T.attached_class)
@@ -49,7 +57,10 @@ module Orb
4957
override.returns(
5058
{
5159
trial_end_date:
52-
Orb::SubscriptionUpdateTrialParams::TrialEndDate::Variants,
60+
T.any(
61+
Time,
62+
Orb::SubscriptionUpdateTrialParams::TrialEndDate::OrSymbol
63+
),
5364
shift: T::Boolean,
5465
request_options: Orb::RequestOptions
5566
}

rbi/orb/resources/subscriptions.rbi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,10 @@ module Orb
14791479
params(
14801480
subscription_id: String,
14811481
trial_end_date:
1482-
Orb::SubscriptionUpdateTrialParams::TrialEndDate::Variants,
1482+
T.any(
1483+
Time,
1484+
Orb::SubscriptionUpdateTrialParams::TrialEndDate::OrSymbol
1485+
),
14831486
shift: T::Boolean,
14841487
request_options: Orb::RequestOptions::OrHash
14851488
).returns(Orb::Models::SubscriptionUpdateTrialResponse)

sig/orb/internal.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Orb
22
module Internal
33
extend Orb::Internal::Util::SorbetRuntimeSupport
44

5+
type file_input = Pathname | StringIO | IO | String | Orb::FilePart
6+
57
OMIT: Object
68
end
79
end

sorbet/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
--dir=rbi
1+
--dir=rbi/
22
--ignore=test/

test/orb/internal/sorbet_runtime_support_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_nil_aliases
2525
err = Orb::Internal::Util::SorbetRuntimeSupport::MissingSorbetRuntimeError
2626

2727
assert_raises(err) { Orb::Internal::AnyHash }
28+
assert_raises(err) { Orb::Internal::FileInput }
2829
assert_raises(err) { Orb::Internal::Type::Converter::Input }
2930
assert_raises(err) { Orb::Internal::Type::Converter::CoerceState }
3031
assert_raises(err) { Orb::Internal::Type::Converter::DumpState }

0 commit comments

Comments
 (0)