Skip to content

Commit

Permalink
Merge pull request #18521 from Homebrew/runtime-req-ans
Browse files Browse the repository at this point in the history
Use requires_ancestor consistently
  • Loading branch information
dduugg authored Oct 7, 2024
2 parents 69941c0 + d3d25be commit 1a1795f
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 52 deletions.
4 changes: 4 additions & 0 deletions Library/Homebrew/attrable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# frozen_string_literal: true

module Attrable
extend T::Helpers

requires_ancestor { Module }

sig { params(attrs: Symbol).void }
def attr_predicate(*attrs)
attrs.each do |attr|
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/attrable.rbi

This file was deleted.

4 changes: 4 additions & 0 deletions Library/Homebrew/cask/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
module Cask
# Helper module for reading and writing cask metadata.
module Metadata
extend T::Helpers

METADATA_SUBDIR = ".metadata"
TIMESTAMP_FORMAT = "%Y%m%d%H%M%S.%L"

requires_ancestor { Cask }

def metadata_main_container_path(caskroom_path: self.caskroom_path)
caskroom_path.join(METADATA_SUBDIR)
end
Expand Down
7 changes: 0 additions & 7 deletions Library/Homebrew/cask/metadata.rbi

This file was deleted.

4 changes: 4 additions & 0 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class AbstractDownloadStrategy

# Extension for bottle downloads.
module Pourable
extend T::Helpers

requires_ancestor { AbstractDownloadStrategy }

def stage
ohai "Pouring #{basename}"
super
Expand Down
4 changes: 0 additions & 4 deletions Library/Homebrew/download_strategy.rbi
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# typed: strict

module AbstractDownloadStrategy::Pourable
requires_ancestor { AbstractDownloadStrategy }
end

# This is a third-party implementation
# rubocop:disable Lint/StructNewOverride
class Mechanize::HTTP
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/downloadable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Downloadable
extend T::Helpers

abstract!
requires_ancestor { Kernel }

sig { overridable.returns(T.nilable(URL)) }
attr_reader :url
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/downloadable.rbi

This file was deleted.

4 changes: 4 additions & 0 deletions Library/Homebrew/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ def initialize(name, path, class_name, class_list)

# Shared methods for formula unreadable errors.
module FormulaUnreadableErrorModule
extend T::Helpers

requires_ancestor { FormulaOrCaskUnavailableError }

attr_reader :formula_error

sig { returns(String) }
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/exceptions.rbi

This file was deleted.

3 changes: 3 additions & 0 deletions Library/Homebrew/extend/ENV/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
# @see Stdenv
# @see https://www.rubydoc.info/stdlib/Env Ruby's ENV API
module SharedEnvExtension
extend T::Helpers
include CompilerConstants

requires_ancestor { Sorbet::Private::Static::ENVClass }

CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS].freeze
private_constant :CC_FLAG_VARS

Expand Down
2 changes: 0 additions & 2 deletions Library/Homebrew/extend/ENV/shared.rbi
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# typed: strict

module SharedEnvExtension
requires_ancestor { Sorbet::Private::Static::ENVClass }

# Overload to allow `PATH` values.
sig {
type_parameters(:U).params(
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
module UnpackStrategy
class Zip
module MacOSZipExtension
extend T::Helpers

requires_ancestor { UnpackStrategy }

private

sig { params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).void }
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/extend/os/mac/unpack_strategy/zip.rbi

This file was deleted.

8 changes: 8 additions & 0 deletions Library/Homebrew/extend/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# frozen_string_literal: true

module DiskUsageExtension
extend T::Helpers

requires_ancestor { Pathname }

sig { returns(Integer) }
def disk_usage
return @disk_usage if defined?(@disk_usage)
Expand Down Expand Up @@ -524,6 +528,10 @@ def rmtree(noop: nil, verbose: nil, secure: nil)
require "context"

module ObserverPathnameExtension
extend T::Helpers

requires_ancestor { Pathname }

class << self
include Context

Expand Down
9 changes: 0 additions & 9 deletions Library/Homebrew/extend/pathname.rbi

This file was deleted.

4 changes: 4 additions & 0 deletions Library/Homebrew/os/linux/elf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# {Pathname} extension for dealing with ELF files.
# @see https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
module ELFShim
extend T::Helpers

MAGIC_NUMBER_OFFSET = 0
private_constant :MAGIC_NUMBER_OFFSET
MAGIC_NUMBER_ASCII = "\x7fELF"
Expand Down Expand Up @@ -40,6 +42,8 @@ module ELFShim
ARCHITECTURE_AARCH64 = 0xB7
private_constant :ARCHITECTURE_AARCH64

requires_ancestor { Pathname }

def read_uint8(offset)
read(1, offset).unpack1("C")
end
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/os/linux/elf.rbi

This file was deleted.

3 changes: 3 additions & 0 deletions Library/Homebrew/os/mac/mach.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# {Pathname} extension for dealing with Mach-O files.
module MachOShim
extend Forwardable
extend T::Helpers

requires_ancestor { Pathname }

delegate [:dylib_id] => :macho

Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/os/mac/mach.rbi

This file was deleted.

0 comments on commit 1a1795f

Please sign in to comment.