Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate remaining hardcoded blank?/present?/presence return values #184

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
102 changes: 102 additions & 0 deletions rbi/annotations/activesupport.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ class ActiveSupport::TimeWithZone
include ::DateAndTime::Zones
# @shim: Methods on ActiveSupport::TimeWithZone are delegated to `Time` using `method_missing
include ::DateAndTime::Calculations

sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class Object
Expand Down Expand Up @@ -157,3 +168,94 @@ class Array
sig { returns(ActiveSupport::ArrayInquirer) }
def inquiry; end
end

class Date
sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class DateTime
sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class NilClass
sig { returns(TrueClass) }
def blank?; end

# @shim: since `present?` is always false, `presence` always returns `nil`
sig { returns(NilClass) }
def presence; end

# @shim: since `blank?` is always true, `present?` always returns `false`
sig { returns(FalseClass) }
def present?; end
end

class FalseClass
sig { returns(TrueClass) }
def blank?; end

# @shim: since `present?` is always false, `presence` always returns `nil`
sig { returns(NilClass) }
def presence; end

# @shim: since `blank?` is always true, `present?` always returns `false`
sig { returns(FalseClass) }
def present?; end
end

class TrueClass
sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class Numeric
sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end

class Time
sig { returns(FalseClass) }
def blank?; end

# @shim: since `present?` is always true, `presence` always returns `self`
sig { returns(T.self_type) }
def presence; end

# @shim: since `blank?` is always false, `present?` always returns `true`
sig { returns(TrueClass) }
def present?; end
end
Loading