Skip to content

Commit

Permalink
Merge pull request #171 from Shopify/uk-relax-strictness
Browse files Browse the repository at this point in the history
Relax strictness of annotation RBI files
  • Loading branch information
paracycle authored Aug 2, 2023
2 parents e162e36 + 4983645 commit 2fc54e9
Show file tree
Hide file tree
Showing 35 changed files with 57 additions and 51 deletions.
8 changes: 7 additions & 1 deletion gem/lib/rbi-central.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ module RBICentral
Include:
- 'rbi/**/*'
Sorbet/StrictSigil:
Sorbet/ValidSigil:
Enabled: true
MinimumStrictness: "true"
SuggestedStrictness: "true"
RequireSigilOnAllFiles: true
Sorbet/EnforceSignatures:
Enabled: true
YML

Expand Down
16 changes: 8 additions & 8 deletions gem/test/rbi-central/cli/check_rubocop_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_rubocop_all_invalid
}
JSON
@repo.write_annotations_file!("gem1", <<~RBI)
# typed: true
# typed: false
module Gem1; end
RBI
Expand All @@ -85,9 +85,9 @@ module Gem2
Linting `gem1`...
Error: rbi/annotations/gem1.rbi:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
# typed: true
^^^^^^^^^^^^^
Error: rbi/annotations/gem1.rbi:1:1: C: Sorbet/ValidSigil: Sorbet sigil should be at least true got false.
# typed: false
^^^^^^^^^^^^^^
Linting `gem2`...
Expand All @@ -111,7 +111,7 @@ def test_rubocop_one_invalid
module Gem1; end
RBI
@repo.write_annotations_file!("gem2", <<~RBI)
# typed: true
# typed: false
module Gem2; end
RBI
Expand All @@ -121,9 +121,9 @@ module Gem2; end
Linting `gem2`...
Error: rbi/annotations/gem2.rbi:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
# typed: true
^^^^^^^^^^^^^
Error: rbi/annotations/gem2.rbi:1:1: C: Sorbet/ValidSigil: Sorbet sigil should be at least true got false.
# typed: false
^^^^^^^^^^^^^^
Some checks failed. See above for details.
ERR
Expand Down
5 changes: 1 addition & 4 deletions gem/test/rbi-central/cli/check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ module Gem2
Linting `gem1`...
Error: rbi/annotations/gem1.rbi:1:1: C: [Correctable] Sorbet/StrictSigil: No Sorbet sigil found in file. Try a typed: strict to start (you can also use rubocop -a to automatically add this).
class Gem1::NotFound; end
^^^^^
rbi/annotations/gem1.rbi:1:1: C: [Correctable] Sorbet/ValidSigil: No Sorbet sigil found in file. Try a typed: true to start (you can also use rubocop -a to automatically add this).
Error: rbi/annotations/gem1.rbi:1:1: C: [Correctable] Sorbet/ValidSigil: No Sorbet sigil found in file. Try a typed: true to start (you can also use rubocop -a to automatically add this).
class Gem1::NotFound; end
^^^^^
Expand Down
8 changes: 4 additions & 4 deletions gem/test/rbi-central/repo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ module Spoom; end

def test_check_rubocop_for_invalid
@repo.write_annotations_file!("gem1", <<~RBI)
# typed: true
# typed: false
module Spoom; end
RBI
errors = @repo.check_rubocop_for(Gem.new(name: "gem1"))
assert_equal(<<~ERR, errors.first&.message)
rbi/annotations/gem1.rbi:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
# typed: true
^^^^^^^^^^^^^
rbi/annotations/gem1.rbi:1:1: C: Sorbet/ValidSigil: Sorbet sigil should be at least true got false.
# typed: false
^^^^^^^^^^^^^^
ERR
end

Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/aasm.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module AASM
mixes_in_class_methods(AASM::ClassMethods)
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/actionmailer.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class ActionMailer::Base
sig { params(headers: T.untyped, block: T.nilable(T.proc.void)).returns(Mail::Message) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/actionpack.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class ActionController::API
MODULES = T.let(T.unsafe(nil), T::Array[T.untyped])
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/actionview.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module ActionView
TemplateError = T.type_alias { Template::Error }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/active_flag.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class ActiveRecord::Base
# @shim: this is included at runtime https://github.com/kenn/active_flag/blob/master/lib/active_flag/railtie.rb#L6
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/activemodel.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class ActiveModel::Errors
Elem = type_member { { fixed: ActiveModel::Error } }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/activerecord.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class ActiveRecord::Schema
sig {params(info: T::Hash[T.untyped, T.untyped], blk: T.proc.bind(ActiveRecord::Schema).void).void}
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/activesupport.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module ActiveSupport::Testing::Declarative
sig { params(name: String, block: T.proc.bind(T.untyped).void).void }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/aws-sdk-acm.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class Aws::ACM::Client
sig { params(params: T.untyped, options: T.untyped).returns(Aws::ACM::Types::DescribeCertificateResponse) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/bencode.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class Array
# Bencodes the Array object. Bencoded arrays are represented as +lxe+, where
Expand Down
5 changes: 1 addition & 4 deletions rbi/annotations/colorize.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class String
extend Colorize::ClassMethods
Expand Down Expand Up @@ -106,9 +106,6 @@ class String
sig { returns(String) }
def red; end

sig { returns(String) }
def swap; end

sig { returns(String) }
def underline; end

Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/configs.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module Configs
sig { params(name: T.any(String, Symbol)).returns(ActiveSupport::HashWithIndifferentAccess) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/delayed_job.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module Delayed::MessageSending
sig { params(options: T.nilable(T::Hash[Symbol, T.untyped])).returns(T.self_type) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/elasticsearch-dsl.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module Elasticsearch::DSL::Search
sig { params(args: T.untyped, block: T.proc.bind(Elasticsearch::DSL::Search::Search).void).void }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/faraday.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module Faraday
class << self
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/globalid.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class ActiveRecord::Base
# @shim: this is included at runtime https://github.com/rails/globalid/blob/v1.0.0/lib/global_id/railtie.rb#L38
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/graphql.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module GraphQL
class << self
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/kredis.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module Kredis::Types
sig { params(key: T.untyped, default: T.untyped, config: T.untyped, after_change: T.untyped, expires_in: T.untyped).returns(Kredis::Types::Scalar) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/lhm-shopify.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module Lhm
extend Lhm
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/lhm.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module Lhm
extend Lhm
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/mocha.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module Mocha::API
sig { params(arguments: T.untyped).returns(Mocha::Mock) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/parse-cron.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

# Parses cron expressions and computes the next occurence of the "job"
class CronParser
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/pundit.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module Pundit::Authorization
sig { void }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/railties.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

module Rails
class << self
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/rainbow.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

module Rainbow
# @shim: https://github.com/sickill/rainbow/blob/master/lib/rainbow.rb#L10-L12
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/shopify-money.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

class Money
sig { returns(BigDecimal) }
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/sidekiq-scheduler.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strong
# typed: true

class SidekiqScheduler::Scheduler
# @shim: Instance methods are made to function as class methods using `method_missing`
Expand Down
5 changes: 4 additions & 1 deletion rbi/annotations/sidekiq.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class Sidekiq::CLI
sig { returns(Sidekiq::CLI) }
Expand All @@ -11,7 +11,10 @@ end
class Sidekiq::Client
private

sig { params(item: T.untyped).returns(T.untyped) }
def normalize_item(item); end

sig { params(item_class: T.untyped).returns(T.untyped) }
def normalized_hash(item_class); end
end

Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/state_machines.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class StateMachines::Machine
include StateMachines::MatcherHelpers
Expand Down
5 changes: 4 additions & 1 deletion rbi/annotations/stripe.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class Stripe::APIResource < Stripe::StripeObject
Elem = type_member { { fixed: T.untyped } }
Expand Down Expand Up @@ -498,6 +498,7 @@ class Stripe::Invoice < Stripe::APIResource
def subtotal; end

# @method_missing: from StripeObject
sig { returns(T::Hash[T.untyped, T.untyped]) }
def status_transitions; end
end

Expand Down Expand Up @@ -525,6 +526,7 @@ class Stripe::InvoiceItem < Stripe::APIResource

# unsure how to represent a StripeObject with specific keys/mmethods without causing typing errors
# @method_missing: from StripeObject
sig { returns(T::Hash[T.untyped, T.untyped]) }
def period; end
end

Expand Down Expand Up @@ -648,6 +650,7 @@ class Stripe::Plan < Stripe::APIResource

# unsure how to represent a StripeObject with specific keys/mmethods without causing typing errors
# @method_missing: from StripeObject
sig { returns(T::Hash[T.untyped, T.untyped]) }
def period; end

# @method_missing: from StripeObject
Expand Down
2 changes: 1 addition & 1 deletion rbi/annotations/webmock.rbi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true

class Minitest::Test
include WebMock::API
Expand Down

0 comments on commit 2fc54e9

Please sign in to comment.