Skip to content

Commit 8184541

Browse files
chore(internal): always run post-processing when formatting when syntax_tree
1 parent 22b703b commit 8184541

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ Style/SafeNavigation:
244244
Style/SignalException:
245245
Exclude:
246246
- Rakefile
247+
- "**/*.rake"
247248

248249
# We use these sparingly, where we anticipate future branches for the
249250
# inner conditional.

Rakefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ multitask(:syntax_tree) do
5959
# 2. at label `l1`, join previously annotated line with `class | module` information.
6060
pst = sed + [subst, "--"]
6161

62+
success = false
63+
6264
# transform class aliases to type aliases, which syntax tree has no trouble with
6365
sh("#{find.shelljoin} | #{pre.shelljoin}")
6466
# run syntax tree to format `*.rbs` files
65-
sh("#{find.shelljoin} | #{fmt.shelljoin}")
67+
sh("#{find.shelljoin} | #{fmt.shelljoin}") do
68+
success = _1
69+
end
6670
# transform type aliases back to class aliases
6771
sh("#{find.shelljoin} | #{pst.shelljoin}")
72+
73+
# always run post-processing to remove comment marker
74+
fail unless success
6875
end
6976

7077
multitask(format: [:ruboformat, :syntax_tree])

lib/openai/internal/type/enum.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ def coerce(value, state:)
114114
#
115115
# @return [String]
116116
def inspect(depth: 0)
117-
return super() if depth.positive?
117+
if depth.positive?
118+
return is_a?(Module) ? super() : self.class.name
119+
end
118120

119121
members = values.map { OpenAI::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
120122
prefix = is_a?(Module) ? name : self.class.name

lib/openai/internal/type/union.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ def dump(value, state:)
215215
#
216216
# @return [String]
217217
def inspect(depth: 0)
218-
return super() if depth.positive?
218+
if depth.positive?
219+
return is_a?(Module) ? super() : self.class.name
220+
end
219221

220222
members = variants.map { OpenAI::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
221223
prefix = is_a?(Module) ? name : self.class.name

0 commit comments

Comments
 (0)