From b43930d1f1ed043834f8aa61ffb2c686a71d0216 Mon Sep 17 00:00:00 2001 From: YutaGoto <12590762+YutaGoto@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:13:45 +0900 Subject: [PATCH 1/6] :label: update types --- Steepfile | 7 +++ rbs_collection.lock.yaml | 109 ++++++++++++++++++++++++------------ rbs_collection.yaml | 2 + sig/ika3/concerns/utils.rbs | 2 +- sig/ika3/schedule.rbs | 6 +- sig/ika3/weapon.rbs | 12 ++-- 6 files changed, 93 insertions(+), 45 deletions(-) diff --git a/Steepfile b/Steepfile index 0b72b08..561ad7e 100644 --- a/Steepfile +++ b/Steepfile @@ -1,8 +1,15 @@ # frozen_string_literal: true +D = Steep::Diagnostic + target :lib do signature 'sig' check 'lib' repo_path '.gem_rbs_collection' + + configure_code_diagnostics do |hash| + hash[D::Ruby::MethodDefinitionMissing] = :warning + hash[D::Ruby::UnknownConstant] = :information + end end diff --git a/rbs_collection.lock.yaml b/rbs_collection.lock.yaml index d667b75..f34fb59 100644 --- a/rbs_collection.lock.yaml +++ b/rbs_collection.lock.yaml @@ -1,9 +1,4 @@ --- -sources: -- name: ruby/gem_rbs_collection - remote: https://github.com/ruby/gem_rbs_collection.git - revision: main - repo_dir: gems path: ".gem_rbs_collection" gems: - name: activesupport @@ -22,6 +17,14 @@ gems: revision: c42c09528dd99252db98f0744181a6de54ec2f55 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems +- name: base64 + version: '0' + source: + type: stdlib +- name: bigdecimal + version: '0' + source: + type: stdlib - name: concurrent-ruby version: '1.1' source: @@ -30,7 +33,15 @@ gems: revision: c42c09528dd99252db98f0744181a6de54ec2f55 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems -- name: csv +- name: connection_pool + version: '2.4' + source: + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: date version: '0' source: type: stdlib @@ -46,6 +57,10 @@ gems: version: '0' source: type: stdlib +- name: forwardable + version: '0' + source: + type: stdlib - name: i18n version: '1.10' source: @@ -58,14 +73,6 @@ gems: version: '0' source: type: stdlib -- name: listen - version: '3.2' - source: - type: git - name: ruby/gem_rbs_collection - revision: c42c09528dd99252db98f0744181a6de54ec2f55 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems - name: logger version: '0' source: @@ -74,6 +81,22 @@ gems: version: '0' source: type: stdlib +- name: monitor + version: '0' + source: + type: stdlib +- name: mutex_m + version: '0' + source: + type: stdlib +- name: net-http + version: '0' + source: + type: stdlib +- name: net-protocol + version: '0' + source: + type: stdlib - name: parallel version: '1.20' source: @@ -82,6 +105,14 @@ gems: revision: c42c09528dd99252db98f0744181a6de54ec2f55 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems +- name: parser + version: '3.2' + source: + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems - name: rainbow version: '3.0' source: @@ -90,30 +121,38 @@ gems: revision: c42c09528dd99252db98f0744181a6de54ec2f55 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems -- name: securerandom - version: '0' +- name: rake + version: '13.0' source: - type: stdlib -- name: steep - version: 1.3.0 - source: - type: rubygems -- name: strscan - version: '0' - source: - type: stdlib -- name: date - version: '0' + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: regexp_parser + version: '2.8' source: - type: stdlib -- name: monitor - version: '0' + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: rubocop + version: '1.57' source: - type: stdlib -- name: mutex_m - version: '0' + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems +- name: rubocop-ast + version: '1.30' source: - type: stdlib + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems - name: singleton version: '0' source: @@ -122,7 +161,7 @@ gems: version: '0' source: type: stdlib -- name: forwardable +- name: timeout version: '0' source: type: stdlib diff --git a/rbs_collection.yaml b/rbs_collection.yaml index a7b853f..d258b80 100644 --- a/rbs_collection.yaml +++ b/rbs_collection.yaml @@ -13,3 +13,5 @@ gems: # It's unnecessary if you don't use rbs as a library. - name: rbs ignore: true + - name: steep + ignore: true diff --git a/sig/ika3/concerns/utils.rbs b/sig/ika3/concerns/utils.rbs index 500876d..2b2a747 100644 --- a/sig/ika3/concerns/utils.rbs +++ b/sig/ika3/concerns/utils.rbs @@ -1,7 +1,7 @@ module Ika3 module Concerns module Utils - def self?.load_yaml_file: (file: String) -> Object + def self?.load_yaml_file: (String) -> Object end end end diff --git a/sig/ika3/schedule.rbs b/sig/ika3/schedule.rbs index 33d708c..aabe45a 100644 --- a/sig/ika3/schedule.rbs +++ b/sig/ika3/schedule.rbs @@ -1,14 +1,14 @@ class Hash[unchecked out K, unchecked out V] < Object - def method_missing: (name: String) -> untyped + def method_missing: (Symbol) -> untyped end module Ika3 class Schedule - def initialize: (contact: String) -> void + def initialize: (String) -> void private - def send_request: (method: String, path: String) -> Object + def send_request: (Symbol, String) -> Object def api_url: () -> "https://spla3.yuu26.com/" diff --git a/sig/ika3/weapon.rbs b/sig/ika3/weapon.rbs index 8f7dcf2..a7f525b 100644 --- a/sig/ika3/weapon.rbs +++ b/sig/ika3/weapon.rbs @@ -4,21 +4,21 @@ module Ika3 include Ika3::Concerns::Utils - def self.find: (untyped weapon_key) -> untyped + def self.find: (String) -> (Exception | Object) - def self.find_by_name: (untyped weapon_name) -> untyped + def self.find_by_name: (String) -> (Exception | Object) - def self.filter_by_sub: (untyped sub_name) -> untyped + def self.filter_by_sub: (String) -> (Exception | Object) - def self.reload_config!: () -> untyped + def self.reload_config!: () -> void private def self.names: () -> Array[Symbol] - def self.weapons: () -> Array[Object] + def self.weapons: () -> Hash[Symbol, String] - def self.sub_weapons: () -> Array[Object] + def self.sub_weapons: () -> Hash[Symbol, String] def self.config: () -> untyped From ca2c08d8861ae35b280579097fbedbeb4a1742df Mon Sep 17 00:00:00 2001 From: YutaGoto <12590762+YutaGoto@users.noreply.github.com> Date: Sat, 3 Feb 2024 00:39:44 +0900 Subject: [PATCH 2/6] :label: add types --- sig/ika3/concerns/utils.rbs | 2 +- sig/ika3/response.rbs | 13 +++++++++++++ sig/ika3/schedule.rbs | 2 +- sig/ika3/version.rbs | 5 +++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 sig/ika3/response.rbs create mode 100644 sig/ika3/version.rbs diff --git a/sig/ika3/concerns/utils.rbs b/sig/ika3/concerns/utils.rbs index 2b2a747..f3cab45 100644 --- a/sig/ika3/concerns/utils.rbs +++ b/sig/ika3/concerns/utils.rbs @@ -1,7 +1,7 @@ module Ika3 module Concerns module Utils - def self?.load_yaml_file: (String) -> Object + def self?.load_yaml_file: (String) -> untyped end end end diff --git a/sig/ika3/response.rbs b/sig/ika3/response.rbs new file mode 100644 index 0000000..93c640a --- /dev/null +++ b/sig/ika3/response.rbs @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Ika3 + class Response + def initialize: (untyped) -> void + + def body: () -> untyped + + def headers: () -> untyped + + def status: () -> untyped + end +end diff --git a/sig/ika3/schedule.rbs b/sig/ika3/schedule.rbs index aabe45a..1ef8594 100644 --- a/sig/ika3/schedule.rbs +++ b/sig/ika3/schedule.rbs @@ -8,7 +8,7 @@ module Ika3 private - def send_request: (Symbol, String) -> Object + def send_request: (Symbol, String) -> untyped def api_url: () -> "https://spla3.yuu26.com/" diff --git a/sig/ika3/version.rbs b/sig/ika3/version.rbs new file mode 100644 index 0000000..2219a96 --- /dev/null +++ b/sig/ika3/version.rbs @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Ika3 + VERSION: String +end From 25a11a2b3756d6fbe7675f4dedf0b4e714659809 Mon Sep 17 00:00:00 2001 From: YutaGoto <12590762+YutaGoto@users.noreply.github.com> Date: Sat, 3 Feb 2024 17:07:24 +0900 Subject: [PATCH 3/6] :label: update rbs collection --- rbs_collection.lock.yaml | 34 +++++++++------------------------- rbs_collection.yaml | 2 ++ 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/rbs_collection.lock.yaml b/rbs_collection.lock.yaml index f34fb59..4cbac9f 100644 --- a/rbs_collection.lock.yaml +++ b/rbs_collection.lock.yaml @@ -6,7 +6,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: c42c09528dd99252db98f0744181a6de54ec2f55 + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: ast @@ -30,7 +30,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: c42c09528dd99252db98f0744181a6de54ec2f55 + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: connection_pool @@ -45,19 +45,11 @@ gems: version: '0' source: type: stdlib -- name: faraday - version: '2.5' - source: - type: git - name: ruby/gem_rbs_collection - revision: c42c09528dd99252db98f0744181a6de54ec2f55 - remote: https://github.com/ruby/gem_rbs_collection.git - repo_dir: gems -- name: fileutils +- name: erb version: '0' source: type: stdlib -- name: forwardable +- name: fileutils version: '0' source: type: stdlib @@ -66,7 +58,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: c42c09528dd99252db98f0744181a6de54ec2f55 + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: json @@ -89,14 +81,6 @@ gems: version: '0' source: type: stdlib -- name: net-http - version: '0' - source: - type: stdlib -- name: net-protocol - version: '0' - source: - type: stdlib - name: parallel version: '1.20' source: @@ -153,19 +137,19 @@ gems: revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems -- name: singleton +- name: securerandom version: '0' source: type: stdlib -- name: time +- name: singleton version: '0' source: type: stdlib -- name: timeout +- name: time version: '0' source: type: stdlib -- name: uri +- name: timeout version: '0' source: type: stdlib diff --git a/rbs_collection.yaml b/rbs_collection.yaml index d258b80..1b70ad9 100644 --- a/rbs_collection.yaml +++ b/rbs_collection.yaml @@ -11,6 +11,8 @@ path: .gem_rbs_collection gems: # Skip loading rbs gem's RBS. # It's unnecessary if you don't use rbs as a library. + - name: faraday + ignore: true - name: rbs ignore: true - name: steep From 764c48986393937fae2c4a80299f9e37f596bd03 Mon Sep 17 00:00:00 2001 From: YutaGoto <12590762+YutaGoto@users.noreply.github.com> Date: Sat, 3 Feb 2024 17:07:56 +0900 Subject: [PATCH 4/6] :label: fix types --- lib/ika3/schedule.rb | 9 +++++---- lib/ika3/weapons.rb | 10 ---------- sig/ika3/concerns/utils.rbs | 2 +- sig/ika3/response.rbs | 12 ++++++++++-- sig/ika3/schedule.rbs | 10 ++++++++-- sig/ika3/weapon.rbs | 18 +++++++++++++----- 6 files changed, 37 insertions(+), 24 deletions(-) diff --git a/lib/ika3/schedule.rb b/lib/ika3/schedule.rb index cadda2a..e0ebbbd 100644 --- a/lib/ika3/schedule.rb +++ b/lib/ika3/schedule.rb @@ -1,14 +1,15 @@ # frozen_string_literal: true class Hash - def respond_to_missing?(sym) - key? name ? true : super + def respond_to_missing?(name) + key?(name) ? true : super end def method_missing(name) - return self[name] if key? name + each do |key, value| + return value if key&.to_sym == name + end - each { |k, v| return v if k.to_s.to_sym == name } super.method_missing(name) end end diff --git a/lib/ika3/weapons.rb b/lib/ika3/weapons.rb index be01433..61201c0 100644 --- a/lib/ika3/weapons.rb +++ b/lib/ika3/weapons.rb @@ -2,16 +2,6 @@ module Ika3 class Weapon - ATTRIBUTES = %i[ - name sub special - ].freeze - - ATTRIBUTES.each do |attribute| - define_method attribute do - self[attribute] - end - end - class << self include Ika3::Concerns::Utils diff --git a/sig/ika3/concerns/utils.rbs b/sig/ika3/concerns/utils.rbs index f3cab45..968b92a 100644 --- a/sig/ika3/concerns/utils.rbs +++ b/sig/ika3/concerns/utils.rbs @@ -1,7 +1,7 @@ module Ika3 module Concerns module Utils - def self?.load_yaml_file: (String) -> untyped + def self?.load_yaml_file: (untyped file) -> untyped end end end diff --git a/sig/ika3/response.rbs b/sig/ika3/response.rbs index 93c640a..e26ec8a 100644 --- a/sig/ika3/response.rbs +++ b/sig/ika3/response.rbs @@ -2,7 +2,15 @@ module Ika3 class Response - def initialize: (untyped) -> void + @raw_body: untyped + + @raw_headers: untyped + + @raw_status: untyped + + @headers: untyped + + def initialize: (untyped faraday_response) -> void def body: () -> untyped @@ -10,4 +18,4 @@ module Ika3 def status: () -> untyped end -end +end \ No newline at end of file diff --git a/sig/ika3/schedule.rbs b/sig/ika3/schedule.rbs index 1ef8594..5b6ad42 100644 --- a/sig/ika3/schedule.rbs +++ b/sig/ika3/schedule.rbs @@ -1,9 +1,15 @@ -class Hash[unchecked out K, unchecked out V] < Object - def method_missing: (Symbol) -> untyped +class ::Hash[unchecked out K, unchecked out V] + def respond_to_missing?: (untyped name) -> untyped + + def method_missing: (::Symbol) -> untyped end module Ika3 class Schedule + @contact: String + + @splat3_connection: untyped + def initialize: (String) -> void private diff --git a/sig/ika3/weapon.rbs b/sig/ika3/weapon.rbs index a7f525b..f2bc289 100644 --- a/sig/ika3/weapon.rbs +++ b/sig/ika3/weapon.rbs @@ -1,10 +1,18 @@ module Ika3 class Weapon - ATTRIBUTES: ::Array[:name | :sub | :special] + self.@cache: untyped - include Ika3::Concerns::Utils + self.@config: untyped - def self.find: (String) -> (Exception | Object) + self.@sub_weapons: untyped + + self.@weapon_hash: untyped + + self.@sub_weapon_hash: untyped + + extend Ika3::Concerns::Utils + + def self.find: (String) -> (Exception | untyped) def self.find_by_name: (String) -> (Exception | Object) @@ -16,9 +24,9 @@ module Ika3 def self.names: () -> Array[Symbol] - def self.weapons: () -> Hash[Symbol, String] + def self.weapons: () -> untyped - def self.sub_weapons: () -> Hash[Symbol, String] + def self.sub_weapons: () -> untyped def self.config: () -> untyped From 9efaf58e1177140c33083d81ffd5dfab09814c97 Mon Sep 17 00:00:00 2001 From: YutaGoto <12590762+YutaGoto@users.noreply.github.com> Date: Sat, 3 Feb 2024 21:20:40 +0900 Subject: [PATCH 5/6] :arrow_up: update gems --- Gemfile.lock | 2 +- ika3.gemspec | 2 +- rbs_collection.lock.yaml | 24 ++++++++++++++++++++++++ rbs_collection.yaml | 2 -- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index caebbab..084191b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: ika3 (0.8.1) - activesupport (>= 5.0.0) + activesupport (>= 6.0.0) faraday (>= 2.7.0) GEM diff --git a/ika3.gemspec b/ika3.gemspec index d2060e4..a3f2c84 100644 --- a/ika3.gemspec +++ b/ika3.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_dependency 'activesupport', '>= 5.0.0' + spec.add_dependency 'activesupport', '>= 6.0.0' spec.add_dependency 'faraday', '>= 2.7.0' # For more information and examples about making a new gem, check out our diff --git a/rbs_collection.lock.yaml b/rbs_collection.lock.yaml index 4cbac9f..e920718 100644 --- a/rbs_collection.lock.yaml +++ b/rbs_collection.lock.yaml @@ -49,10 +49,22 @@ gems: version: '0' source: type: stdlib +- name: faraday + version: '2.5' + source: + type: git + name: ruby/gem_rbs_collection + revision: 846c09971455f0e144cef2f5a6c9fe6d8905d3e1 + remote: https://github.com/ruby/gem_rbs_collection.git + repo_dir: gems - name: fileutils version: '0' source: type: stdlib +- name: forwardable + version: '0' + source: + type: stdlib - name: i18n version: '1.10' source: @@ -81,6 +93,14 @@ gems: version: '0' source: type: stdlib +- name: net-http + version: '0' + source: + type: stdlib +- name: net-protocol + version: '0' + source: + type: stdlib - name: parallel version: '1.20' source: @@ -153,4 +173,8 @@ gems: version: '0' source: type: stdlib +- name: uri + version: '0' + source: + type: stdlib gemfile_lock_path: Gemfile.lock diff --git a/rbs_collection.yaml b/rbs_collection.yaml index 1b70ad9..d258b80 100644 --- a/rbs_collection.yaml +++ b/rbs_collection.yaml @@ -11,8 +11,6 @@ path: .gem_rbs_collection gems: # Skip loading rbs gem's RBS. # It's unnecessary if you don't use rbs as a library. - - name: faraday - ignore: true - name: rbs ignore: true - name: steep From b2319867e4bbb2759db7d96d2a10661a554dcff8 Mon Sep 17 00:00:00 2001 From: YutaGoto <12590762+YutaGoto@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:49:33 +0900 Subject: [PATCH 6/6] :label: fix load file type --- sig/ika3/concerns/utils.rbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sig/ika3/concerns/utils.rbs b/sig/ika3/concerns/utils.rbs index 968b92a..f3cab45 100644 --- a/sig/ika3/concerns/utils.rbs +++ b/sig/ika3/concerns/utils.rbs @@ -1,7 +1,7 @@ module Ika3 module Concerns module Utils - def self?.load_yaml_file: (untyped file) -> untyped + def self?.load_yaml_file: (String) -> untyped end end end