Skip to content

Commit 1ceb1dc

Browse files
authored
Merge branch 'master' into byte-offset
2 parents d36a956 + 3a9c363 commit 1ceb1dc

File tree

4 files changed

+103
-4
lines changed

4 files changed

+103
-4
lines changed

Gemfile.lock

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/soutaro/steep.git
3-
revision: c8549eae3ca6aa7e93d225d69fa909593f6938d1
3+
revision: 86f2b023c454f84964c6bab4aef0aafb0610c088
44
specs:
55
steep (2.0.0.dev)
66
activesupport (>= 5.1)
@@ -49,7 +49,7 @@ GEM
4949
minitest (>= 5.1)
5050
securerandom (>= 0.3)
5151
tzinfo (~> 2.0, >= 2.0.5)
52-
addressable (2.8.8)
52+
addressable (2.8.9)
5353
public_suffix (>= 2.0.2, < 8.0)
5454
ast (2.4.3)
5555
base64 (0.3.0)
@@ -92,6 +92,8 @@ GEM
9292
rb-inotify (~> 0.9, >= 0.9.10)
9393
logger (1.7.0)
9494
marcel (1.1.0)
95+
mcp (0.8.0)
96+
json-schema (>= 4.1)
9597
memory_profiler (1.1.0)
9698
minitest (6.0.2)
9799
drb (~> 2.0)
@@ -144,14 +146,15 @@ GEM
144146
rspec-expectations (3.13.5)
145147
diff-lcs (>= 1.2.0, < 2.0)
146148
rspec-support (~> 3.13.0)
147-
rspec-mocks (3.13.7)
149+
rspec-mocks (3.13.8)
148150
diff-lcs (>= 1.2.0, < 2.0)
149151
rspec-support (~> 3.13.0)
150152
rspec-support (3.13.7)
151-
rubocop (1.84.2)
153+
rubocop (1.85.0)
152154
json (~> 2.3)
153155
language_server-protocol (~> 3.17.0.2)
154156
lint_roller (~> 1.1.0)
157+
mcp (~> 0.6)
155158
parallel (~> 1.10)
156159
parser (>= 3.3.0.2)
157160
rainbow (>= 2.2.2, < 4.0)

include/rbs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#ifndef RBS_H
22
#define RBS_H
33

4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
48
#include "rbs/parser.h"
59

10+
#ifdef __cplusplus
11+
}
12+
#endif
13+
614
#endif

stdlib/psych/0/psych.rbs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,56 @@ module Psych
400400
#
401401
%a{annotate:rdoc:copy:Psych.unsafe_load}
402402
def self.unsafe_load: (String yaml, ?filename: String | _ToStr | _ToS?, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool, ?strict_integer: bool) -> untyped
403+
404+
# <!--
405+
# rdoc-file=ext/psych/lib/psych.rb
406+
# - safe_load_file(filename, **kwargs)
407+
# -->
408+
# Safely loads the document contained in `filename`. Returns the yaml contained
409+
# in `filename` as a Ruby object, or if the file is empty, it returns the
410+
# specified `fallback` return value, which defaults to `nil`. See safe_load for
411+
# options.
412+
#
413+
%a{annotate:rdoc:copy:Psych.safe_load_file}
414+
def self.safe_load_file: (path, ?permitted_classes: Array[Class], ?permitted_symbols: Array[Symbol], ?aliases: bool, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool) -> untyped
415+
416+
# <!--
417+
# rdoc-file=ext/psych/lib/psych.rb
418+
# - unsafe_load_file(filename, **kwargs)
419+
# -->
420+
# Load the document contained in `filename`. Returns the yaml contained in
421+
# `filename` as a Ruby object, or if the file is empty, it returns the specified
422+
# `fallback` return value, which defaults to `false`.
423+
#
424+
# NOTE: This method *should not* be used to parse untrusted documents, such as
425+
# YAML documents that are supplied via user input. Instead, please use the
426+
# safe_load_file method.
427+
#
428+
%a{annotate:rdoc:copy:Psych.unsafe_load_file}
429+
def self.unsafe_load_file: (path, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool) -> untyped
430+
431+
class Exception < ::RuntimeError
432+
end
433+
434+
class SyntaxError < ::Psych::Exception
435+
attr_reader file: String?
436+
attr_reader line: Integer?
437+
attr_reader column: Integer?
438+
attr_reader offset: Integer?
439+
attr_reader problem: String?
440+
attr_reader context: String?
441+
442+
# <!--
443+
# rdoc-file=ext/psych/lib/psych/syntax_error.rb
444+
# - new(file, line, col, offset, problem, context)
445+
# -->
446+
#
447+
def initialize: (?String? file, ?Integer? line, ?Integer? column, ?Integer? offset, ?String? problem, ?String? context) -> void
448+
end
449+
450+
class BadAlias < ::Psych::Exception
451+
end
452+
453+
class DisallowedClass < ::Psych::Exception
454+
end
403455
end

test/stdlib/psych_test.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,42 @@ def test_safe_load
5959
)
6060
end
6161

62+
def test_safe_load_file
63+
Dir.mktmpdir do |dir|
64+
(Pathname(dir) + "test.yaml").write(<<-YAML)
65+
foo: 123
66+
YAML
67+
68+
assert_send_type(
69+
"(::String) -> untyped",
70+
Psych, :safe_load_file, File.join(dir, "test.yaml")
71+
)
72+
73+
assert_send_type(
74+
"(::_ToPath, permitted_classes: ::Array[::Class], permitted_symbols: ::Array[::Symbol], aliases: bool, fallback: ::Symbol, symbolize_names: bool, freeze: bool) -> untyped",
75+
Psych, :safe_load_file, Pathname(File.join(dir, "test.yaml")), permitted_classes: [Integer], permitted_symbols: [:foo], aliases: true, fallback: :foo, symbolize_names: true, freeze: false
76+
)
77+
end
78+
end
79+
80+
def test_unsafe_load_file
81+
Dir.mktmpdir do |dir|
82+
(Pathname(dir) + "test.yaml").write(<<-YAML)
83+
foo: 123
84+
YAML
85+
86+
assert_send_type(
87+
"(::String) -> untyped",
88+
Psych, :unsafe_load_file, File.join(dir, "test.yaml")
89+
)
90+
91+
assert_send_type(
92+
"(::_ToPath, fallback: ::String, symbolize_names: bool, freeze: bool) -> untyped",
93+
Psych, :unsafe_load_file, Pathname(File.join(dir, "test.yaml")), fallback: "foo", symbolize_names: false, freeze: false
94+
)
95+
end
96+
end
97+
6298
def test_dump
6399
assert_send_type(
64100
"(::Array[::Integer]) -> ::String",

0 commit comments

Comments
 (0)