Merge pull request #18521 from Homebrew/runtime-req-ans

Use requires_ancestor consistently
This commit is contained in:
Douglas Eichelberger 2024-10-07 07:41:03 -07:00 committed by GitHub
commit 1a1795fa9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 39 additions and 52 deletions

View File

@ -2,6 +2,10 @@
# frozen_string_literal: true # frozen_string_literal: true
module Attrable module Attrable
extend T::Helpers
requires_ancestor { Module }
sig { params(attrs: Symbol).void } sig { params(attrs: Symbol).void }
def attr_predicate(*attrs) def attr_predicate(*attrs)
attrs.each do |attr| attrs.each do |attr|

View File

@ -1,5 +0,0 @@
# typed: strict
module Attrable
requires_ancestor { Module }
end

View File

@ -4,9 +4,13 @@
module Cask module Cask
# Helper module for reading and writing cask metadata. # Helper module for reading and writing cask metadata.
module Metadata module Metadata
extend T::Helpers
METADATA_SUBDIR = ".metadata" METADATA_SUBDIR = ".metadata"
TIMESTAMP_FORMAT = "%Y%m%d%H%M%S.%L" TIMESTAMP_FORMAT = "%Y%m%d%H%M%S.%L"
requires_ancestor { Cask }
def metadata_main_container_path(caskroom_path: self.caskroom_path) def metadata_main_container_path(caskroom_path: self.caskroom_path)
caskroom_path.join(METADATA_SUBDIR) caskroom_path.join(METADATA_SUBDIR)
end end

View File

@ -1,7 +0,0 @@
# typed: strict
module Cask
module Metadata
requires_ancestor { Cask }
end
end

View File

@ -31,6 +31,10 @@ class AbstractDownloadStrategy
# Extension for bottle downloads. # Extension for bottle downloads.
module Pourable module Pourable
extend T::Helpers
requires_ancestor { AbstractDownloadStrategy }
def stage def stage
ohai "Pouring #{basename}" ohai "Pouring #{basename}"
super super

View File

@ -1,9 +1,5 @@
# typed: strict # typed: strict
module AbstractDownloadStrategy::Pourable
requires_ancestor { AbstractDownloadStrategy }
end
# This is a third-party implementation # This is a third-party implementation
# rubocop:disable Lint/StructNewOverride # rubocop:disable Lint/StructNewOverride
class Mechanize::HTTP class Mechanize::HTTP

View File

@ -10,6 +10,7 @@ module Downloadable
extend T::Helpers extend T::Helpers
abstract! abstract!
requires_ancestor { Kernel }
sig { overridable.returns(T.nilable(URL)) } sig { overridable.returns(T.nilable(URL)) }
attr_reader :url attr_reader :url

View File

@ -1,5 +0,0 @@
# typed: strict
module Downloadable
requires_ancestor { Kernel }
end

View File

@ -197,6 +197,10 @@ end
# Shared methods for formula unreadable errors. # Shared methods for formula unreadable errors.
module FormulaUnreadableErrorModule module FormulaUnreadableErrorModule
extend T::Helpers
requires_ancestor { FormulaOrCaskUnavailableError }
attr_reader :formula_error attr_reader :formula_error
sig { returns(String) } sig { returns(String) }

View File

@ -1,5 +0,0 @@
# typed: strict
module FormulaUnreadableErrorModule
requires_ancestor { FormulaOrCaskUnavailableError }
end

View File

@ -11,8 +11,11 @@ require "development_tools"
# @see Stdenv # @see Stdenv
# @see https://www.rubydoc.info/stdlib/Env Ruby's ENV API # @see https://www.rubydoc.info/stdlib/Env Ruby's ENV API
module SharedEnvExtension module SharedEnvExtension
extend T::Helpers
include CompilerConstants include CompilerConstants
requires_ancestor { Sorbet::Private::Static::ENVClass }
CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS].freeze CC_FLAG_VARS = %w[CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS].freeze
private_constant :CC_FLAG_VARS private_constant :CC_FLAG_VARS

View File

@ -1,8 +1,6 @@
# typed: strict # typed: strict
module SharedEnvExtension module SharedEnvExtension
requires_ancestor { Sorbet::Private::Static::ENVClass }
# Overload to allow `PATH` values. # Overload to allow `PATH` values.
sig { sig {
type_parameters(:U).params( type_parameters(:U).params(

View File

@ -6,6 +6,10 @@ require "system_command"
module UnpackStrategy module UnpackStrategy
class Zip class Zip
module MacOSZipExtension module MacOSZipExtension
extend T::Helpers
requires_ancestor { UnpackStrategy }
private private
sig { params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).void } sig { params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).void }

View File

@ -1,5 +0,0 @@
# typed: strict
module UnpackStrategy::Zip::MacOSZipExtension
requires_ancestor { UnpackStrategy }
end

View File

@ -2,6 +2,10 @@
# frozen_string_literal: true # frozen_string_literal: true
module DiskUsageExtension module DiskUsageExtension
extend T::Helpers
requires_ancestor { Pathname }
sig { returns(Integer) } sig { returns(Integer) }
def disk_usage def disk_usage
return @disk_usage if defined?(@disk_usage) return @disk_usage if defined?(@disk_usage)
@ -524,6 +528,10 @@ require "extend/os/pathname"
require "context" require "context"
module ObserverPathnameExtension module ObserverPathnameExtension
extend T::Helpers
requires_ancestor { Pathname }
class << self class << self
include Context include Context

View File

@ -1,9 +0,0 @@
# typed: strict
module DiskUsageExtension
requires_ancestor { Pathname }
end
module ObserverPathnameExtension
requires_ancestor { Pathname }
end

View File

@ -6,6 +6,8 @@ require "os/linux/ld"
# {Pathname} extension for dealing with ELF files. # {Pathname} extension for dealing with ELF files.
# @see https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header # @see https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
module ELFShim module ELFShim
extend T::Helpers
MAGIC_NUMBER_OFFSET = 0 MAGIC_NUMBER_OFFSET = 0
private_constant :MAGIC_NUMBER_OFFSET private_constant :MAGIC_NUMBER_OFFSET
MAGIC_NUMBER_ASCII = "\x7fELF" MAGIC_NUMBER_ASCII = "\x7fELF"
@ -40,6 +42,8 @@ module ELFShim
ARCHITECTURE_AARCH64 = 0xB7 ARCHITECTURE_AARCH64 = 0xB7
private_constant :ARCHITECTURE_AARCH64 private_constant :ARCHITECTURE_AARCH64
requires_ancestor { Pathname }
def read_uint8(offset) def read_uint8(offset)
read(1, offset).unpack1("C") read(1, offset).unpack1("C")
end end

View File

@ -1,5 +0,0 @@
# typed: strict
module ELFShim
requires_ancestor { Pathname }
end

View File

@ -6,6 +6,9 @@ require "macho"
# {Pathname} extension for dealing with Mach-O files. # {Pathname} extension for dealing with Mach-O files.
module MachOShim module MachOShim
extend Forwardable extend Forwardable
extend T::Helpers
requires_ancestor { Pathname }
delegate [:dylib_id] => :macho delegate [:dylib_id] => :macho

View File

@ -1,5 +0,0 @@
# typed: strict
module MachOShim
requires_ancestor { Pathname }
end