From 3ce1a652f8b2caa80faac1bf6d92b3c95d43f914 Mon Sep 17 00:00:00 2001 From: Nicholas La Roux Date: Sun, 25 Jan 2026 13:39:30 -0500 Subject: [PATCH] Drop support for >1 year deprecated #sorbet_type method Method #sorbet_type was deprecated in favour of #__tapioca_type in mid-December 2024. - 9298261e15763011053f54b58e752d067715a704 - https://github.com/Shopify/tapioca/pull/2125 --- .../dsl/compilers/json_api_client_resource.rb | 16 +---- .../json_api_client_resource_spec.rb | 67 ------------------- 2 files changed, 3 insertions(+), 80 deletions(-) diff --git a/lib/tapioca/dsl/compilers/json_api_client_resource.rb b/lib/tapioca/dsl/compilers/json_api_client_resource.rb index 46036b41e..d45a24574 100644 --- a/lib/tapioca/dsl/compilers/json_api_client_resource.rb +++ b/lib/tapioca/dsl/compilers/json_api_client_resource.rb @@ -138,17 +138,7 @@ def type_for(property) type = ::JsonApiClient::Schema::TypeFactory.type_for(property.type) return "T.untyped" if type.nil? - sorbet_type = if type.respond_to?(:sorbet_type) - line, file = type.method(:sorbet_type).source_location - - $stderr.puts <<~MESSAGE - WARNING: `#sorbet_type` is deprecated. Please rename your method to `#__tapioca_type`." - - Defined on line #{line} of #{file} - MESSAGE - - type.sorbet_type - elsif type.respond_to?(:__tapioca_type) + tapioca_type = if type.respond_to?(:__tapioca_type) type.__tapioca_type elsif type == ::JsonApiClient::Schema::Types::Integer "::Integer" @@ -167,9 +157,9 @@ def type_for(property) end if property.default.nil? - as_nilable_type(sorbet_type) + as_nilable_type(tapioca_type) else - sorbet_type + tapioca_type end end diff --git a/spec/tapioca/dsl/compilers/json_api_client_resource_spec.rb b/spec/tapioca/dsl/compilers/json_api_client_resource_spec.rb index e30e96638..6b16b0de9 100644 --- a/spec/tapioca/dsl/compilers/json_api_client_resource_spec.rb +++ b/spec/tapioca/dsl/compilers/json_api_client_resource_spec.rb @@ -368,73 +368,6 @@ def tag_count=(tag_count); end assert_equal(expected, rbi_for(:Post)) end - - it "prints a warning that #sorbet_type is deprecated" do - add_ruby_file("post.rb", <<~RUBY) - class CustomType - def self.sorbet_type - "Integer" - end - end - - class Post < JsonApiClient::Resource - property :comment_count, type: :custom_type - property :tag_count, type: :custom_type, default: 0 - end - RUBY - - expected = <<~RBI - # typed: strong - - class Post - include JsonApiClientResourceGeneratedMethods - - module JsonApiClientResourceGeneratedMethods - sig { returns(T.nilable(Integer)) } - def comment_count; end - - sig { params(comment_count: T.nilable(Integer)).returns(T.nilable(Integer)) } - def comment_count=(comment_count); end - - sig { returns(Integer) } - def tag_count; end - - sig { params(tag_count: Integer).returns(Integer) } - def tag_count=(tag_count); end - end - end - RBI - - assert_output(nil, /WARNING: `#sorbet_type` is deprecated./) do - assert_equal(expected, rbi_for(:Post)) - end - end - - it "does not crash if the source location #sorbet_type is unknown" do - add_ruby_file("post.rb", <<~RUBY) - class CustomType - def self.sorbet_type - "Integer" - end - - def self.method(name) - m = super - # Fake the source location, as if this was defined in a C extension. - def m.source_location - nil - end - m - end - end - - class Post < JsonApiClient::Resource - property :comment_count, type: :custom_type - property :tag_count, type: :custom_type, default: 0 - end - RUBY - - rbi_for(:Post) # Should not raise - end end end end