Skip to content

Commit 050e207

Browse files
authored
Merge branch 'master' into fix-for-strict_unused_block
2 parents d8269a8 + b0f7f94 commit 050e207

File tree

2 files changed

+53
-51
lines changed

2 files changed

+53
-51
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require:
33
- rubocop-on-rbs
44

55
AllCops:
6-
TargetRubyVersion: 3.0
6+
TargetRubyVersion: 3.1
77
DisabledByDefault: true
88
Exclude:
99
- 'vendor/bundle/**/*'

stdlib/json/0/json.rbs

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,6 @@ interface _ToJson
22
def to_json: (?JSON::State state) -> String
33
end
44

5-
interface _JsonToWritableIO
6-
def to_io: () -> _JsonWrite
7-
end
8-
9-
interface _JsonWrite
10-
def write: (String json) -> void
11-
12-
def flush: () -> void
13-
end
14-
15-
interface _JsonReadableIO
16-
def to_io: () -> _JsonRead
17-
end
18-
19-
interface _JsonRead
20-
def read: () -> string
21-
end
22-
23-
type json_options = Hash[Symbol, untyped]
24-
255
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
266
# The base exception for JSON errors.
277
#
@@ -96,10 +76,6 @@ end
9676
class JSON::Pure::Parser
9777
end
9878

99-
type json_generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
100-
type json_parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
101-
type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
102-
10379
# <!-- rdoc-file=ext/json/lib/json.rb -->
10480
# # JavaScript Object Notation (JSON)
10581
#
@@ -675,6 +651,32 @@ type json_state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure:
675651
# With custom addition: #<Foo:0x0000000006473bb8 @bar=0, @baz=1> (Foo)
676652
#
677653
module JSON
654+
type options = Hash[Symbol, untyped]
655+
656+
type generator = singleton(::JSON::Ext::Generator) | singleton(::JSON::Pure::Generator)
657+
658+
type parser = singleton(::JSON::Ext::Parser) | singleton(::JSON::Pure::Parser)
659+
660+
type state = singleton(JSON::Ext::Generator::State) | singleton(JSON::Pure::Generator::State)
661+
662+
interface _WritableIO
663+
def to_io: () -> _Write
664+
end
665+
666+
interface _Write
667+
def write: (String json) -> void
668+
669+
def flush: () -> void
670+
end
671+
672+
interface _ReadableIO
673+
def to_io: () -> _Read
674+
end
675+
676+
interface _Read
677+
def read: () -> string
678+
end
679+
678680
# <!--
679681
# rdoc-file=ext/json/lib/json/common.rb
680682
# - JSON[object] -> new_array or new_string
@@ -689,7 +691,7 @@ module JSON
689691
# ruby = [0, 1, nil]
690692
# JSON[ruby] # => '[0,1,null]'
691693
#
692-
def self.[]: (untyped object, ?json_options opts) -> untyped
694+
def self.[]: (untyped object, ?options opts) -> untyped
693695

694696
# <!--
695697
# rdoc-file=ext/json/lib/json/common.rb
@@ -744,22 +746,22 @@ module JSON
744746
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
745747
#
746748
def self?.dump: (_ToJson obj, ?Integer limit) -> String
747-
| (_ToJson obj, _JsonToWritableIO anIO) -> _JsonWrite
748-
| (_ToJson obj, _JsonWrite anIO, ?Integer limit) -> _JsonWrite
749+
| (_ToJson obj, _WritableIO anIO) -> _Write
750+
| (_ToJson obj, _Write anIO, ?Integer limit) -> _Write
749751

750752
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
751753
# Sets or returns the default options for the JSON.dump method. Initially:
752754
# opts = JSON.dump_default_options
753755
# opts # => {:max_nesting=>false, :allow_nan=>true}
754756
#
755-
def self.dump_default_options: () -> json_options
757+
def self.dump_default_options: () -> options
756758

757759
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
758760
# Sets or returns the default options for the JSON.dump method. Initially:
759761
# opts = JSON.dump_default_options
760762
# opts # => {:max_nesting=>false, :allow_nan=>true}
761763
#
762-
def self.dump_default_options=: (json_options) -> json_options
764+
def self.dump_default_options=: (options) -> options
763765

764766
# <!--
765767
# rdoc-file=ext/json/lib/json/common.rb
@@ -776,7 +778,7 @@ module JSON
776778
# # Raises SystemStackError (stack level too deep):
777779
# JSON.fast_generate(a)
778780
#
779-
def self?.fast_generate: (_ToJson obj, ?json_options opts) -> String
781+
def self?.fast_generate: (_ToJson obj, ?options opts) -> String
780782

781783
alias self.fast_unparse self.fast_generate
782784

@@ -819,14 +821,14 @@ module JSON
819821
# # Raises JSON::NestingError (nesting of 100 is too deep):
820822
# JSON.generate(a)
821823
#
822-
def self?.generate: (_ToJson obj, ?json_options opts) -> String
824+
def self?.generate: (_ToJson obj, ?options opts) -> String
823825

824826
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
825827
# Returns the JSON generator module that is used by JSON.
826828
#
827-
def self.generator: () -> json_generator
829+
def self.generator: () -> generator
828830

829-
def self.generator=: (json_generator generator) -> void
831+
def self.generator=: (generator generator) -> void
830832

831833
# <!--
832834
# rdoc-file=ext/json/lib/json/common.rb
@@ -972,7 +974,7 @@ module JSON
972974
# #<Admin:0x00000000064c41f8
973975
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
974976
#
975-
def self?.load: (string | _JsonReadableIO | _JsonRead source, ?Proc proc, ?json_options options) -> untyped
977+
def self?.load: (string | _ReadableIO | _Read source, ?Proc proc, ?options options) -> untyped
976978

977979
# <!--
978980
# rdoc-file=ext/json/lib/json/common.rb
@@ -983,7 +985,7 @@ module JSON
983985
#
984986
# See method #parse.
985987
#
986-
def self?.load_file: (string path, ?json_options opts) -> untyped
988+
def self?.load_file: (string path, ?options opts) -> untyped
987989

988990
# <!--
989991
# rdoc-file=ext/json/lib/json/common.rb
@@ -994,21 +996,21 @@ module JSON
994996
#
995997
# See method #parse!
996998
#
997-
def self?.load_file!: (string path, ?json_options opts) -> untyped
999+
def self?.load_file!: (string path, ?options opts) -> untyped
9981000

9991001
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
10001002
# Sets or returns default options for the JSON.load method. Initially:
10011003
# opts = JSON.load_default_options
10021004
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
10031005
#
1004-
def self.load_default_options: () -> json_options
1006+
def self.load_default_options: () -> options
10051007

10061008
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
10071009
# Sets or returns default options for the JSON.load method. Initially:
10081010
# opts = JSON.load_default_options
10091011
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
10101012
#
1011-
def self.load_default_options=: (json_options) -> json_options
1013+
def self.load_default_options=: (options) -> options
10121014

10131015
# <!--
10141016
# rdoc-file=ext/json/lib/json/common.rb
@@ -1059,7 +1061,7 @@ module JSON
10591061
# # Raises JSON::ParserError (783: unexpected token at ''):
10601062
# JSON.parse('')
10611063
#
1062-
def self?.parse: (string source, ?json_options opts) -> untyped
1064+
def self?.parse: (string source, ?options opts) -> untyped
10631065

10641066
# <!--
10651067
# rdoc-file=ext/json/lib/json/common.rb
@@ -1075,14 +1077,14 @@ module JSON
10751077
# checking for nesting depth.
10761078
# * Option `allow_nan`, if not provided, defaults to `true`.
10771079
#
1078-
def self?.parse!: (string source, ?json_options opts) -> untyped
1080+
def self?.parse!: (string source, ?options opts) -> untyped
10791081

10801082
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
10811083
# Returns the JSON parser class that is used by JSON.
10821084
#
1083-
def self.parser: () -> json_parser
1085+
def self.parser: () -> parser
10841086

1085-
def self.parser=: (json_parser parser) -> void
1087+
def self.parser=: (parser parser) -> void
10861088

10871089
# <!--
10881090
# rdoc-file=ext/json/lib/json/common.rb
@@ -1116,7 +1118,7 @@ module JSON
11161118
# }
11171119
# }
11181120
#
1119-
def self?.pretty_generate: (_ToJson obj, ?json_options opts) -> untyped
1121+
def self?.pretty_generate: (_ToJson obj, ?options opts) -> untyped
11201122

11211123
alias self.pretty_unparse self.pretty_generate
11221124

@@ -1144,19 +1146,19 @@ module JSON
11441146
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
11451147
# Sets or Returns the JSON generator state class that is used by JSON.
11461148
#
1147-
def self.state: () -> json_state
1149+
def self.state: () -> state
11481150

11491151
# <!-- rdoc-file=ext/json/lib/json/common.rb -->
11501152
# Sets or Returns the JSON generator state class that is used by JSON.
11511153
#
1152-
def self.state=: (json_state) -> json_state
1154+
def self.state=: (state) -> state
11531155

11541156
alias self.unparse self.generate
11551157

11561158
alias unparse generate
11571159
end
11581160

1159-
JSON::FAST_STATE_PROTOTYPE: json_state
1161+
JSON::FAST_STATE_PROTOTYPE: JSON::state
11601162

11611163
JSON::Infinity: Float
11621164

@@ -1166,9 +1168,9 @@ JSON::MinusInfinity: Float
11661168

11671169
JSON::NaN: Float
11681170

1169-
JSON::PRETTY_STATE_PROTOTYPE: json_state
1171+
JSON::PRETTY_STATE_PROTOTYPE: JSON::state
11701172

1171-
JSON::SAFE_STATE_PROTOTYPE: json_state
1173+
JSON::SAFE_STATE_PROTOTYPE: JSON::state
11721174

11731175
JSON::VERSION: String
11741176

@@ -1213,8 +1215,8 @@ module Kernel
12131215
# The *opts* argument is passed through to generate/parse respectively. See
12141216
# generate and parse for their documentation.
12151217
#
1216-
def JSON: (string source, ?json_options opts) -> untyped
1217-
| (_ToJson obj, ?json_options opts) -> String
1218+
def JSON: (string source, ?JSON::options opts) -> untyped
1219+
| (_ToJson obj, ?JSON::options opts) -> String
12181220
end
12191221

12201222
%a{annotate:rdoc:skip}

0 commit comments

Comments
 (0)