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

Avoid T.must. #16624

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,23 +540,13 @@ def oldname
# Old names for the formula.
sig { returns(T::Array[String]) }
def oldnames
@oldnames ||= if tap
T.must(tap).formula_oldnames.fetch(name, [])
else
[]
end
@oldnames ||= tap&.formula_oldnames&.dig(name) || []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect tap to ever be not nil but formula_oldnames is nil?

If not, the existing code but just without the T.must feels nicer to me than repeatedly chaining &

end

# All aliases for the formula.
sig { returns(T::Array[String]) }
def aliases
@aliases ||= if tap
T.must(tap).alias_reverse_table[full_name].to_a.map do |a|
a.split("/").last
end
else
[]
end
@aliases ||= tap&.alias_reverse_table&.dig(full_name)&.map { _1.split("/").last } || []
end

# The {Resource}s for the currently active {SoftwareSpec}.
Expand Down