Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: typecheck.yml
on:
pull_request:
jobs:
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true

- name: Install RBS collections
run: rbs collection install

- name: Run type checker
run: bundle exec steep check --severity-level=error
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ yarn-debug.log*
/lib/bundler/man/

# End of https://www.toptal.com/developers/gitignore/api/rails,ruby

.gem_rbs_collection
.idea
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ group :development, :test do
gem 'rake'
gem 'rubocop'
gem 'simplecov', require: false
gem 'steep', require: false
gem 'vcr'
gem 'webmock'
end
38 changes: 38 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ GEM
bigdecimal (3.3.1)
byebug (12.0.0)
cgi (0.5.2)
concurrent-ruby (1.3.8)
crack (1.0.1)
bigdecimal
rexml
csv (3.3.6)
docile (1.4.1)
drb (2.2.3)
excon (1.3.1)
Expand All @@ -34,10 +36,17 @@ GEM
net-http (~> 0.5)
faraday-retry (2.4.0)
faraday (~> 2.0)
ffi (1.17.4)
ffi (1.17.4-x86_64-darwin)
fileutils (1.8.0)
hashdiff (1.2.1)
json (2.20.0)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
listen (3.10.0)
logger
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.7.0)
minitest (6.0.6)
drb (~> 2.0)
Expand All @@ -57,6 +66,13 @@ GEM
racc (1.8.1)
rainbow (3.1.1)
rake (13.3.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (4.1.2)
logger
prism (>= 1.6.0)
tsort
regexp_parser (2.11.3)
rexml (3.4.4)
rubocop (1.81.7)
Expand All @@ -75,12 +91,33 @@ GEM
prism (~> 1.4)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
securerandom (0.4.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
steep (2.0.0)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
fileutils (>= 1.1.0)
json (>= 2.1.0)
language_server-protocol (>= 3.17.0.4, < 4.0)
listen (~> 3.0)
logger (>= 1.3.0)
parser (>= 3.2)
prism (>= 0.25.0)
rainbow (>= 2.2.2, < 4.0)
rbs (~> 4.0)
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 5)
uri (>= 0.12.0)
strscan (3.1.8)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
tsort (0.2.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.2.0)
Expand Down Expand Up @@ -109,6 +146,7 @@ DEPENDENCIES
rake
rubocop
simplecov
steep
vcr
webmock

Expand Down
6 changes: 6 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

target :lib do
check 'lib'
signature 'sig'
end
3 changes: 2 additions & 1 deletion data_services_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Gem::Specification.new do |spec|
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.4'

spec.files = Dir.glob('lib/**/*', File::FNM_DOTMATCH) + ['LICENSE.txt', 'README.md']
spec.files = Dir.glob('{lib/**/*,sig/**/*.rbs}',
File::FNM_DOTMATCH) + ['LICENSE.txt', 'README.md']
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.extra_rdoc_files = Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt']
spec.require_paths = ['lib']
Expand Down
2 changes: 1 addition & 1 deletion lib/data_services_api/aspect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(json, service)
@service = service
end

def id
def id # steep:ignore MethodBodyTypeMismatch
@json['@id']
end

Expand Down
6 changes: 3 additions & 3 deletions lib/data_services_api/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def initialize(json, service)
@service = service
end

def id
def id # steep:ignore MethodBodyTypeMismatch
@json['@id']
end

def method_missing(attribute)
respond_to_missing?(attribute) ? @json[attribute.to_s] : super
respond_to_missing?(attribute, nil) ? @json[attribute.to_s] : super
end

def respond_to_missing?(attribute, _args = nil)
Expand All @@ -26,7 +26,7 @@ def data_api
@json['data-api']
end

def dataset
def dataset # steep:ignore MethodBodyTypeMismatch
@json['dataset']
end

Expand Down
2 changes: 1 addition & 1 deletion lib/data_services_api/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def perform_request(http_url, method, query_params = nil) # rubocop:disable Metr

def create_http_connection(http_url) # rubocop:disable Metrics/MethodLength
Faraday.new(url: http_url) do |config|
config.options[:timeout] = @connection_timeout
config.options.timeout = @connection_timeout
config.use Faraday::Request::UrlEncoded
config.use Faraday::FollowRedirects::Middleware

Expand Down
14 changes: 7 additions & 7 deletions lib/data_services_api/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ def initialize(base = {}, adds = {})
end

def value
self[:@value]
self['@value']
end

def type
self[:@type]
def type # steep:ignore MethodBodyTypeMismatch
self['@type']
end

def uri
self[:@id]
def uri # steep:ignore MethodBodyTypeMismatch
self['@id']
end

def with_uri(uri)
Value.new(self, '@id': uri)
Value.new(self, { '@id' => uri })
end

def self.uri(uri)
Value.new.with_uri(uri)
end

def with_typed_value(value, type)
Value.new(self, '@value': value, '@type': type)
Value.new(self, { '@value' => value, '@type' => type })
end

def with_year_month(year, month)
Expand Down
Loading