Skip to content

Commit

Permalink
Replace every String | Symbol to interned keyword
Browse files Browse the repository at this point in the history
`interned` is defined as alias for `Symbol | string` in RBS 3.3.
ref: ruby/rbs#1469
  • Loading branch information
m11o committed Jan 29, 2024
1 parent 846c099 commit 2b6bd68
Show file tree
Hide file tree
Showing 43 changed files with 202 additions and 213 deletions.
90 changes: 45 additions & 45 deletions gems/activerecord/6.0/activerecord.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module ActiveRecord
def self.columns: () -> Array[untyped]
def self.reflect_on_all_associations: (?Symbol) -> Array[untyped]

def will_save_change_to_attribute?: (String | Symbol attr_name, ?from: untyped, ?to: untyped) -> bool
def will_save_change_to_attribute?: (interned attr_name, ?from: untyped, ?to: untyped) -> bool

def save!: (?context: Symbol | Array[Symbol] context, ?validate: bool, ?touch: bool) -> void
def save: (?context: Symbol | Array[Symbol] context, ?validate: bool, ?touch: bool) -> bool
Expand Down Expand Up @@ -295,22 +295,22 @@ module ActiveRecord
def all: () -> self
def ids: () -> Array[PrimaryKey]
def none: () -> self
def pluck: (Symbol | String column) -> Array[untyped]
| (*Symbol | String columns) -> Array[Array[untyped]]
def pluck: (interned column) -> Array[untyped]
| (*interned columns) -> Array[Array[untyped]]
def where: (*untyped) -> self
def not: (*untyped) -> self
def exists?: (*untyped) -> bool
def order: (*untyped) -> self
def group: (*Symbol | String) -> untyped
def group: (*interned) -> untyped
def distinct: () -> self
def or: (self) -> self
def merge: (Array[untyped] | Hash[untyped, untyped] | ActiveRecord::Relation | Proc) -> self
def joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def includes: (*String | Symbol | Hash[untyped, untyped]) -> self
def eager_load: (*String | Symbol | Hash[untyped, untyped]) -> self
def preload: (*String | Symbol | Hash[untyped, untyped]) -> self
def joins: (*interned | Hash[untyped, untyped]) -> self
def left_joins: (*interned | Hash[untyped, untyped]) -> self
def left_outer_joins: (*interned | Hash[untyped, untyped]) -> self
def includes: (*interned | Hash[untyped, untyped]) -> self
def eager_load: (*interned | Hash[untyped, untyped]) -> self
def preload: (*interned | Hash[untyped, untyped]) -> self
def find_by: (*untyped) -> Model?
def find_by!: (*untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -362,17 +362,17 @@ module ActiveRecord
def destroy_by: (*untyped) -> untyped
def delete_by: (*untyped) -> untyped
def each: () { (Model) -> void } -> self
def select: (*Symbol | String) -> self
def select: (*interned) -> self
| () { (Model) -> boolish } -> Array[Model]
def reselect: (*Symbol | String) -> self
def reselect: (*interned) -> self
end

module ClassMethods[Model, Relation, PrimaryKey]
def all: () -> Relation
def ids: () -> Array[PrimaryKey]
def none: () -> Relation
def pluck: (Symbol | String column) -> Array[untyped]
| (*Symbol | String columns) -> Array[Array[untyped]]
def pluck: (interned column) -> Array[untyped]
| (*interned columns) -> Array[Array[untyped]]
def where: (*untyped) -> Relation
def exists?: (*untyped) -> bool
def any?: () -> bool
Expand All @@ -384,16 +384,16 @@ module ActiveRecord
def one?: () -> bool
| () { (Model) -> boolish } -> bool
def order: (*untyped) -> Relation
def group: (*Symbol | String) -> untyped
def group: (*interned) -> untyped
def distinct: () -> Relation
def or: (Relation) -> Relation
def merge: (Array[untyped] | Hash[untyped, untyped] | ActiveRecord::Relation | Proc) -> Relation
def joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def includes: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def eager_load: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def preload: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def joins: (*interned | Hash[untyped, untyped]) -> Relation
def left_joins: (*interned | Hash[untyped, untyped]) -> Relation
def left_outer_joins: (*interned | Hash[untyped, untyped]) -> Relation
def includes: (*interned | Hash[untyped, untyped]) -> Relation
def eager_load: (*interned | Hash[untyped, untyped]) -> Relation
def preload: (*interned | Hash[untyped, untyped]) -> Relation
def find_by: (*untyped) -> Model?
def find_by!: (*untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -443,9 +443,9 @@ module ActiveRecord
def touch_all: (*untyped, ?time: untyped) -> untyped
def destroy_by: (*untyped) -> untyped
def delete_by: (*untyped) -> untyped
def select: (*Symbol | String) -> Relation
def select: (*interned) -> Relation
| () { (Model) -> boolish } -> Array[Model]
def reselect: (*Symbol | String) -> Relation
def reselect: (*interned) -> Relation
end
end
end
Expand All @@ -454,22 +454,22 @@ interface _ActiveRecord_Relation[Model, PrimaryKey]
def all: () -> self
def ids: () -> Array[PrimaryKey]
def none: () -> self
def pluck: (Symbol | String column) -> Array[untyped]
| (*Symbol | String columns) -> Array[Array[untyped]]
def pluck: (interned column) -> Array[untyped]
| (*interned columns) -> Array[Array[untyped]]
def where: (*untyped) -> self
def not: (*untyped) -> self
def exists?: (*untyped) -> bool
def order: (*untyped) -> self
def group: (*Symbol | String) -> untyped
def group: (*interned) -> untyped
def distinct: () -> self
def or: (self) -> self
def merge: (Array[untyped] | Hash[untyped, untyped] | ActiveRecord::Relation | Proc) -> self
def joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> self
def includes: (*String | Symbol | Hash[untyped, untyped]) -> self
def eager_load: (*String | Symbol | Hash[untyped, untyped]) -> self
def preload: (*String | Symbol | Hash[untyped, untyped]) -> self
def joins: (*interned | Hash[untyped, untyped]) -> self
def left_joins: (*interned | Hash[untyped, untyped]) -> self
def left_outer_joins: (*interned | Hash[untyped, untyped]) -> self
def includes: (*interned | Hash[untyped, untyped]) -> self
def eager_load: (*interned | Hash[untyped, untyped]) -> self
def preload: (*interned | Hash[untyped, untyped]) -> self
def find_by: (untyped, *untyped) -> Model?
def find_by!: (untyped, *untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -522,17 +522,17 @@ interface _ActiveRecord_Relation[Model, PrimaryKey]
def destroy_by: (*untyped) -> untyped
def delete_by: (*untyped) -> untyped
def each: () { (Model) -> void } -> self
def select: (*Symbol | String) -> self
def select: (*interned) -> self
| () { (Model) -> boolish } -> Array[Model]
def reselect: (*Symbol | String) -> self
def reselect: (*interned) -> self
end

interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
def all: () -> Relation
def ids: () -> Array[PrimaryKey]
def none: () -> Relation
def pluck: (Symbol | String column) -> Array[untyped]
| (*Symbol | String columns) -> Array[Array[untyped]]
def pluck: (interned column) -> Array[untyped]
| (*interned columns) -> Array[Array[untyped]]
def where: (*untyped) -> Relation
def exists?: (*untyped) -> bool
def any?: () -> bool
Expand All @@ -544,16 +544,16 @@ interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
def one?: () -> bool
| () { (Model) -> boolish } -> bool
def order: (*untyped) -> Relation
def group: (*Symbol | String) -> untyped
def group: (*interned) -> untyped
def distinct: () -> Relation
def or: (Relation) -> Relation
def merge: (Array[untyped] | Hash[untyped, untyped] | ActiveRecord::Relation | Proc) -> Relation
def joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def left_outer_joins: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def includes: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def eager_load: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def preload: (*String | Symbol | Hash[untyped, untyped]) -> Relation
def joins: (*interned | Hash[untyped, untyped]) -> Relation
def left_joins: (*interned | Hash[untyped, untyped]) -> Relation
def left_outer_joins: (*interned | Hash[untyped, untyped]) -> Relation
def includes: (*interned | Hash[untyped, untyped]) -> Relation
def eager_load: (*interned | Hash[untyped, untyped]) -> Relation
def preload: (*interned | Hash[untyped, untyped]) -> Relation
def find_by: (untyped) -> Model?
def find_by!: (untyped) -> Model
def find: (PrimaryKey id) -> Model
Expand Down Expand Up @@ -604,9 +604,9 @@ interface _ActiveRecord_Relation_ClassMethods[Model, Relation, PrimaryKey]
def touch_all: (*untyped, ?time: untyped) -> untyped
def destroy_by: (*untyped) -> untyped
def delete_by: (*untyped) -> untyped
def select: (*Symbol | String) -> Relation
def select: (*interned) -> Relation
| () { (Model) -> boolish } -> Array[Model]
def reselect: (*Symbol | String) -> Relation
def reselect: (*interned) -> Relation
def scope: (Symbol, ^(*untyped, **untyped) [self: Relation] -> void) ?{ (Module extention) [self: Relation] -> void } -> void
end

Expand Down
4 changes: 2 additions & 2 deletions gems/activerecord/7.0/activerecord-7.0.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module ActiveRecord

module Enum
def enum: (**untyped options) -> void
| ((String | Symbol) name, **untyped options) -> void
| ((String | Symbol) name, (Hash[(Symbol | String), untyped] | Array[Symbol | String]) values, **untyped options) -> void
| (interned name, **untyped options) -> void
| (interned name, (Hash[interned, untyped] | Array[interned]) values, **untyped options) -> void
end

module RuntimeRegistry
Expand Down
2 changes: 1 addition & 1 deletion gems/activestorage/6.0/lib/reflection.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module ActiveStorage
# User.reflect_on_attachment(:avatar)
# # => the avatar reflection
#
def reflect_on_attachment: ((String | Symbol) attachment) -> (ActiveStorage::Reflection::HasOneAttachedReflection | ActiveStorage::Reflection::HasManyAttachedReflection | nil)
def reflect_on_attachment: ((interned) attachment) -> (ActiveStorage::Reflection::HasOneAttachedReflection | ActiveStorage::Reflection::HasManyAttachedReflection | nil)
end
end
end
Expand Down
29 changes: 10 additions & 19 deletions gems/activesupport/6.0/activesupport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module ActiveSupport
def compile_methods!: () -> void

# Compiles reader methods so we don't have to go through method_missing.
def self.compile_methods!: (Array[Symbol | String] keys) -> void
def self.compile_methods!: (Array[interned] keys) -> void
end

module ClassMethods
Expand All @@ -28,8 +28,7 @@ module ActiveSupport

private

# TODO: Fix to use `interned` in names params after releasing ruby/rbs#1499
def config_accessor: (*(String | Symbol) names, ?instance_accessor: bool instance_accessor, ?instance_writer: bool instance_writer, ?instance_reader: bool instance_reader) ?{ () -> untyped } -> void
def config_accessor: (*interned names, ?instance_accessor: bool instance_accessor, ?instance_writer: bool instance_writer, ?instance_reader: bool instance_reader) ?{ () -> untyped } -> void
end

def config: () -> InheritableOptions
Expand Down Expand Up @@ -265,11 +264,9 @@ module ActiveSupport
class OrderedOptions < Hash[Symbol, untyped]
alias _get []

# TODO: Fix to use `interned` in key params after releasing ruby/rbs#1499
def []=: ((String | Symbol) key, untyped value) -> untyped
def []=: (interned key, untyped value) -> untyped

# TODO: Fix to use `interned` in key params after releasing ruby/rbs#1499
def []: ((String | Symbol) key) -> untyped
def []: (interned key) -> untyped

def method_missing: (Symbol name, *untyped args) -> untyped

Expand All @@ -279,8 +276,7 @@ module ActiveSupport
end

class InheritableOptions < OrderedOptions
# TODO: Fix to use `interned` in parent params after releasing ruby/rbs#1499
def initialize: (?Hash[(String | Symbol), untyped]? parent) -> void
def initialize: (?Hash[interned, untyped]? parent) -> void

def inheritable_copy: () -> instance
end
Expand Down Expand Up @@ -327,27 +323,22 @@ class Module
def mattr_accessor: (*untyped syms, ?default: untyped? default, ?instance_accessor: bool instance_accessor, ?instance_writer: bool instance_writer, ?instance_reader: bool instance_reader) ?{ () -> untyped } -> untyped
| ...

# TODO: Fix to use `interned` in attrs params after releasing ruby/rbs#1499
def attr_internal_reader: (*(Symbol | String) attrs) -> void
def attr_internal_reader: (*interned attrs) -> void

# TODO: Fix to use `interned` in attrs params after releasing ruby/rbs#1499
def attr_internal_writer: (*(Symbol | String) attrs) -> void
def attr_internal_writer: (*interned attrs) -> void

# TODO: Fix to use `interned` in attrs params after releasing ruby/rbs#1499
def attr_internal_accessor: (*(Symbol | String) attrs) -> void
def attr_internal_accessor: (*interned attrs) -> void

alias attr_internal attr_internal_accessor

attr_accessor self.attr_internal_naming_format: String

private

# TODO: Fix to use `interned` in attr params after releasing ruby/rbs#1499
def attr_internal_ivar_name: ((Symbol | String) attr) -> String
def attr_internal_ivar_name: (interned attr) -> String

type access_type = :reader | :writer
# TODO: Fix to use `interned` in attr params after releasing ruby/rbs#1499
def attr_internal_define: ((Symbol | String) attr_name, access_type `type`) -> void
def attr_internal_define: (interned attr_name, access_type `type`) -> void
end

class Integer
Expand Down
4 changes: 2 additions & 2 deletions gems/carrierwave/3.0/carrierwave.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ module CarrierWave

module Versions
module ClassMethods
def version: (String | Symbol name, **untyped) ? { () -> void } -> void
def version: (interned name, **untyped) ? { () -> void } -> void
end

def versions: () -> Hash[Symbol, CarrierWave::Uploader::Base]
def version_name: () -> String
def version_exists?: (String | Symbol) -> bool
def version_exists?: (interned) -> bool
def cache: (*untyped) -> void
def url: (*Symbol) -> String
| (Hash[untyped, untyped]) -> String
Expand Down
2 changes: 1 addition & 1 deletion gems/chunky_png/1.4.0/chunky_png.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ module ChunkyPNG
extend DataUrlImporting

module PNGEncoding
type constraints = Hash[Symbol | String, untyped] | Symbol
type constraints = Hash[interned, untyped] | Symbol

def write: (IO io, ?constraints constraints) -> void

Expand Down
2 changes: 1 addition & 1 deletion gems/chunky_png/1.4.0/color.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ module ChunkyPNG
# 255. Overrides any opacity value given in the color name.
# @return [Integer] The color value.
# @raise [ChunkyPNG::Exception] If the color name was not recognized.
def html_color: (Symbol | String color_name, ?Integer? opacity) -> Integer
def html_color: (interned color_name, ?Integer? opacity) -> Integer

# @return [Integer] Black pixel/color
BLACK: Integer
Expand Down
6 changes: 3 additions & 3 deletions gems/circuitbox/2.0/circuitbox.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Circuitbox

extend Configuration

# def self.circuit: [T] (String | Symbol service_name, Hash[untyped, untyped] options) ?{ () -> T } -> (CircuitBreaker | T)
def self.circuit: (String | Symbol service_name, Hash[untyped, untyped] options) -> CircuitBreaker
| [T] (String | Symbol service_name, Hash[untyped, untyped] options) ?{ () -> T } -> T
# def self.circuit: [T] (interned service_name, Hash[untyped, untyped] options) ?{ () -> T } -> (CircuitBreaker | T)
def self.circuit: (interned service_name, Hash[untyped, untyped] options) -> CircuitBreaker
| [T] (interned service_name, Hash[untyped, untyped] options) ?{ () -> T } -> T
end
2 changes: 1 addition & 1 deletion gems/faker/2.23/faker.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Faker

class Config
def self.random=: (Random | nil) -> Random
def self.locale=: (Symbol | String) -> (Symbol | String)
def self.locale=: (interned) -> interned
end

class Name < Base
Expand Down
Loading

0 comments on commit 2b6bd68

Please sign in to comment.