-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RBS signature files to support static type checking
And also add CI for RBS
- Loading branch information
Showing
14 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Aws | ||
attr_reader self.config: Hash[Symbol, untyped] | ||
|
||
def self.config=: (Hash[Symbol, untyped] config) -> Hash[Symbol, untyped] | ||
|
||
def self.use_bundled_cert!: () -> String | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Aws | ||
module ClientStubs | ||
def stub_responses: (Symbol operation_name, *untyped stubs) -> void | ||
|
||
def api_requests: () -> Array[{ operation_name: Symbol, params: untyped, context: untyped }] | ||
|
||
def stub_data: (Symbol operation_name, untyped data) -> untyped | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Aws | ||
module Errors | ||
class NonSupportedRubyVersionError < RuntimeError | ||
end | ||
|
||
# The base class for all errors returned by an Amazon Web Service. | ||
# All ~400 level client errors and ~500 level server errors are raised | ||
# as service errors. This indicates it was an error returned from the | ||
# service and not one generated by the client. | ||
class ServiceError < RuntimeError | ||
def initialize: (untyped context, String message, ?untyped data) -> void | ||
|
||
attr_reader code: String | ||
|
||
attr_reader context: untyped | ||
|
||
attr_reader data: untyped | ||
|
||
attr_accessor self.code: String | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
gems/aws-sdk-core/sig/aws-sdk-core/resources/collection.rbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Aws | ||
module Resources | ||
class Collection[T] | ||
include Enumerable[T] | ||
|
||
def initialize: (Enumerable[Enumerable[T]] batches, ?size: Integer, ?limit: Integer) -> void | ||
|
||
def each: () -> Enumerator[T, untyped] | ||
| () { (T) -> untyped } -> Enumerator[T, untyped] | ||
|
||
def size: () -> Integer? | ||
|
||
alias length size | ||
|
||
def first: () -> T? | ||
| (Integer) -> self | ||
|
||
def limit: (Integer) -> self | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Aws | ||
class EmptyStructure | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Aws | ||
module Waiters | ||
module Errors | ||
class WaiterFailed < StandardError | ||
end | ||
|
||
class FailureStateError < WaiterFailed | ||
end | ||
|
||
class TooManyAttemptsError < WaiterFailed | ||
end | ||
|
||
class UnexpectedError < WaiterFailed | ||
end | ||
|
||
class NoSuchWaiterError < ArgumentError | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Seahorse | ||
module Client | ||
class Base | ||
include HandlerBuilder | ||
|
||
def self.new: (?untyped options) -> instance | ||
def self.add_plugin: (untyped plugin) -> untyped | ||
def self.remove_plugin: (untyped plugin) -> untyped | ||
def self.clear_plugins: () -> untyped | ||
def self.set_plugins: (Array[untyped] plugins) -> untyped | ||
def self.plugins: () -> Array[untyped] | ||
def self.api: () -> untyped | ||
def self.set_api: (untyped api) -> untyped | ||
def self.define: (?untyped options) -> untyped | ||
|
||
attr_reader config: untyped | ||
|
||
attr_reader handlers: untyped | ||
|
||
def build_request: (_ToS operation_name, ?untyped params) -> untyped | ||
|
||
def operation_names: () -> Array[Symbol] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Seahorse | ||
module Client | ||
# This module provides the ability to add handlers to a class or | ||
# module. The including class or extending module must respond to | ||
# `#handlers`, returning a {HandlerList}. | ||
module HandlerBuilder | ||
def handle_request: (*untyped) { (untyped context) -> void } -> untyped | ||
|
||
def handle_response: (*untyped) { (untyped resp) -> void } -> untyped | ||
|
||
def handle: (*untyped) ?{ (untyped context) -> void } -> untyped | ||
|
||
alias handler handle | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Seahorse | ||
module Client | ||
# <!-- | ||
# RBS does not support Delegator. | ||
# the behavior is mimicked `Seahorse::Client::Response` as much as possible. | ||
# --> | ||
interface _Response[DATA] | ||
def context: () -> untyped | ||
|
||
def data: () -> DATA? | ||
def data=: (DATA?) -> DATA? | ||
|
||
def error: () -> ::StandardError? | ||
def error=: (::StandardError?) -> ::StandardError? | ||
|
||
def checksum_validated: () -> ::String? | ||
|
||
def on: (Integer) { (self) -> void } -> self | ||
| (Range[Integer]) { (self) -> void } -> self | ||
|
||
def on_success: () { (self) -> void } -> self | ||
|
||
def successful?: () -> bool | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace :rbs do | ||
task :validate do | ||
require 'rubygems' | ||
|
||
all_gems = Dir.glob("gems/*").map{File.basename(_1)}.to_set | ||
|
||
sigs = [] | ||
Dir.glob('gems/*/sig').each do |dir| | ||
sdk_gem = dir.sub(%r{gems/(.*)/sig}, '\1') | ||
spec = Gem::Specification::load("gems/#{sdk_gem}/#{sdk_gem}.gemspec") | ||
deps = spec.dependencies.select do |d| | ||
all_gems.include?(d.name) && File.directory?("gems/#{d.name}/sig") | ||
end.map { |d| d.name } | ||
|
||
puts "Validating gem `#{sdk_gem}` with deps #{deps}" | ||
sh("bundle exec rbs #{deps.map{"-I gems/#{_1}/sig"}.join(' ')} -I #{dir} validate --silent") do |ok, _| | ||
sigs << File.basename(File.dirname(dir)) unless ok | ||
end | ||
end | ||
abort('one or more rbs validate failed: %s' % [sigs.join(', ')]) unless sigs.empty? | ||
end | ||
end |