Skip to content

Commit 78df5af

Browse files
fix(internal): ensure formatting always uses c.utf-8 locale
1 parent 6f83977 commit 78df5af

881 files changed

Lines changed: 27937 additions & 17580 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rubocop.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Layout/MultilineMethodParameterLineBreaks:
6363
# Prefer compact hash literals.
6464
Layout/SpaceInsideHashLiteralBraces:
6565
EnforcedStyle: no_space
66+
Exclude:
67+
- "**/*.rbi"
6668

6769
Lint/BooleanSymbol:
6870
Enabled: false
@@ -90,6 +92,10 @@ Lint/MissingSuper:
9092
Exclude:
9193
- "**/*.rbi"
9294

95+
Lint/SymbolConversion:
96+
Exclude:
97+
- "**/*.rbi"
98+
9399
# Disabled for safety reasons, this option changes code semantics.
94100
Lint/UnusedMethodArgument:
95101
AutoCorrect: false
@@ -244,6 +250,10 @@ Style/RedundantInitialize:
244250
Exclude:
245251
- "**/*.rbi"
246252

253+
Style/RedundantParentheses:
254+
Exclude:
255+
- "**/*.rbi"
256+
247257
# Prefer slashes for regex literals.
248258
Style/RegexpLiteral:
249259
EnforcedStyle: slashes

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/stainless-api/syntax_tree-rbs.git
3-
revision: 140eb3ba2ff4b959b345ac2a7927cd758a9f1284
3+
revision: c30b50219918be7cfe3ef803a00b59d1e77fcada
44
branch: main
55
specs:
66
syntax_tree-rbs (1.0.0)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ Sorbet's typed enums require sub-classing of the [`T::Enum` class](https://sorbe
192192
Since this library does not depend on `sorbet-runtime`, it uses a [`T.all` intersection type](https://sorbet.org/docs/intersection-types) with a ruby primitive type to construct a "tagged alias" instead.
193193

194194
```ruby
195-
module Lithic::Models::AccountFinancialAccountType
195+
module Lithic::AccountFinancialAccountType
196196
# This alias aids language service driven navigation.
197-
TaggedSymbol = T.type_alias { T.all(Symbol, Lithic::Models::AccountFinancialAccountType) }
197+
TaggedSymbol = T.type_alias { T.all(Symbol, Lithic::AccountFinancialAccountType) }
198198
end
199199
```
200200

Rakefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,40 @@ multitask(:test) do
3434
ruby(*%w[-w -e], rb, verbose: false) { fail unless _1 }
3535
end
3636

37-
rubo_find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
3837
xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --]
38+
locale = {"LC_ALL" => "C.UTF-8"}
3939

4040
desc("Lint `*.rb(i)`")
4141
multitask(:"lint:rubocop") do
42+
find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
43+
4244
rubocop = %w[rubocop --fail-level E]
4345
rubocop += %w[--format github] if ENV.key?("CI")
4446

4547
# some lines cannot be shortened
4648
rubocop += %w[--except Lint/RedundantCopDisableDirective,Layout/LineLength]
4749

4850
lint = xargs + rubocop
49-
sh("#{rubo_find.shelljoin} | #{lint.shelljoin}")
51+
sh("#{find.shelljoin} | #{lint.shelljoin}")
5052
end
5153

52-
desc("Format `*.rb(i)`")
53-
multitask(:"format:rubocop") do
54+
desc("Format `*.rb`")
55+
multitask(:"format:rb") do
56+
# while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support
57+
find = %w[find ./lib ./test -type f -and -name *.rb -print0]
5458
fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --]
55-
sh("#{rubo_find.shelljoin} | #{fmt.shelljoin}")
59+
sh("#{find.shelljoin} | #{fmt.shelljoin}")
60+
end
61+
62+
desc("Format `*.rbi`")
63+
multitask(:"format:rbi") do
64+
find = %w[find ./rbi -type f -and -name *.rbi -print0]
65+
fmt = xargs + %w[stree write --]
66+
sh(locale, "#{find.shelljoin} | #{fmt.shelljoin}")
5667
end
5768

5869
desc("Format `*.rbs`")
59-
multitask(:"format:syntax_tree") do
70+
multitask(:"format:rbs") do
6071
find = %w[find ./sig -type f -name *.rbs -print0]
6172
inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? ["-i", ""] : %w[-i]
6273
uuid = SecureRandom.uuid
@@ -88,7 +99,7 @@ multitask(:"format:syntax_tree") do
8899
# transform class aliases to type aliases, which syntax tree has no trouble with
89100
sh("#{find.shelljoin} | #{pre.shelljoin}")
90101
# run syntax tree to format `*.rbs` files
91-
sh("#{find.shelljoin} | #{fmt.shelljoin}") do
102+
sh(locale, "#{find.shelljoin} | #{fmt.shelljoin}") do
92103
success = _1
93104
end
94105
# transform type aliases back to class aliases
@@ -99,7 +110,7 @@ multitask(:"format:syntax_tree") do
99110
end
100111

101112
desc("Format everything")
102-
multitask(format: [:"format:rubocop", :"format:syntax_tree"])
113+
multitask(format: [:"format:rb", :"format:rbi", :"format:rbs"])
103114

104115
desc("Typecheck `*.rbs`")
105116
multitask(:"typecheck:steep") do

lib/lithic.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
require_relative "lithic/models/transfer"
321321
require_relative "lithic/models/transfer_create_params"
322322
require_relative "lithic/models/verification_method"
323+
require_relative "lithic/models"
323324
require_relative "lithic/resources/account_holders"
324325
require_relative "lithic/resources/accounts"
325326
require_relative "lithic/resources/aggregate_balances"

lib/lithic/client.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,11 @@ class Client < Lithic::Internal::Transport::BaseClient
104104
#
105105
# @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil]
106106
#
107-
# @return [Lithic::Models::APIStatus]
107+
# @return [Lithic::APIStatus]
108108
#
109109
# @see Lithic::Models::ClientAPIStatusParams
110110
def api_status(params = {})
111-
request(
112-
method: :get,
113-
path: "v1/status",
114-
model: Lithic::Models::APIStatus,
115-
options: params[:request_options]
116-
)
111+
request(method: :get, path: "v1/status", model: Lithic::APIStatus, options: params[:request_options])
117112
end
118113

119114
# @api private

lib/lithic/file_part.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def initialize(content, filename: nil, content_type: nil)
4545
@filename =
4646
case content
4747
in Pathname
48-
filename.nil? ? content.basename.to_path : File.basename(filename)
48+
filename.nil? ? content.basename.to_path : ::File.basename(filename)
4949
else
50-
filename.nil? ? nil : File.basename(filename)
50+
filename.nil? ? nil : ::File.basename(filename)
5151
end
5252
@content_type = content_type
5353
end

lib/lithic/internal/type/enum.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ module Type
1717
# values safely.
1818
#
1919
# @example
20-
# # `account_financial_account_type` is a `Lithic::Models::AccountFinancialAccountType`
20+
# # `account_financial_account_type` is a `Lithic::AccountFinancialAccountType`
2121
# case account_financial_account_type
22-
# when Lithic::Models::AccountFinancialAccountType::ISSUING
22+
# when Lithic::AccountFinancialAccountType::ISSUING
2323
# # ...
24-
# when Lithic::Models::AccountFinancialAccountType::OPERATING
24+
# when Lithic::AccountFinancialAccountType::OPERATING
2525
# # ...
2626
# else
2727
# puts(account_financial_account_type)

lib/lithic/internal/type/request_parameters.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module Internal
55
module Type
66
# @api private
77
module RequestParameters
8-
# @!parse
9-
# # Options to specify HTTP behaviour for this request.
10-
# # @return [Lithic::RequestOptions, Hash{Symbol=>Object}]
11-
# attr_accessor :request_options
8+
# @!attribute request_options
9+
# Options to specify HTTP behaviour for this request.
10+
#
11+
# @return [Lithic::RequestOptions, Hash{Symbol=>Object}]
1212

1313
# @param mod [Module]
1414
def self.included(mod)

lib/lithic/internal/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class << self
535535
filename = ERB::Util.url_encode(val.filename)
536536
y << "; filename=\"#{filename}\""
537537
in Pathname | IO
538-
filename = ERB::Util.url_encode(File.basename(val.to_path))
538+
filename = ERB::Util.url_encode(::File.basename(val.to_path))
539539
y << "; filename=\"#{filename}\""
540540
else
541541
end

0 commit comments

Comments
 (0)