Skip to content

Commit

Permalink
Use ruff 0.6 as code formatter (#207)
Browse files Browse the repository at this point in the history
* Use ruff 0.6 as code formatter

* Update requirements
  • Loading branch information
relf authored Aug 28, 2024
1 parent 7843e98 commit 15b3ded
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions app/lib/whats_opt/code_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,19 @@ def _comment_header(filepath)
end

def _format_code(dir)
cmd = "#{PYTHON} -m black --line-length 100 #{dir}"
Rails.logger.info cmd
stdouterr, status = Open3.capture2e(cmd)
unless status.success?
Rails.logger.warn "Black formatting failed!"
Rails.logger.warn "#{stdouterr}"
# ["black", "ruff"].each do |formatter|
["ruff"].each do |formatter|
cmd = if formatter == "ruff"
"#{PYTHON} -m #{formatter} format --line-length 100 #{dir}"
else
"#{PYTHON} -m #{formatter} --line-length 100 #{dir}"
end
Rails.logger.info cmd
stdouterr, status = Open3.capture2e(cmd)
unless status.success?
Rails.logger.warn "#{formatter.capitalize} formatting failed!"
Rails.logger.warn "#{stdouterr}"
end
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion services/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ smt~=2.6.2
salib~=1.4.7
thrift~=0.20.0
openturns~=1.21.0
egobox~=0.20.0
egobox~=0.21.0
ruff~=0.6.0

0 comments on commit 15b3ded

Please sign in to comment.