aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rose <offbyone@github.com>2023-11-04 11:23:00 -0700
committerGitHub <noreply@github.com>2023-11-04 18:23:00 +0000
commit392028d823cfe8804a3d97f9bc2a4c4b283e6c74 (patch)
tree098f385b6e553c41057a63b00c02c09b8136faba
parent4178439d438c923f1baccebb63e1edfb00a257a1 (diff)
Add support for the ruff python formatter (#236)
This adds support, but does not make it the default Fixes: #233 --------- Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
-rw-r--r--CHANGELOG.md3
-rw-r--r--apheleia-formatters.el5
-rw-r--r--test/formatters/installers/ruff.bash2
-rw-r--r--test/formatters/samplecode/ruff/in.py4
-rw-r--r--test/formatters/samplecode/ruff/out.py3
5 files changed, 17 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30af85c..1d7cb8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -69,6 +69,8 @@ The format is based on [Keep a Changelog].
* [`rubocop`](https://github.com/rubocop/rubocop) for [ruby](https://www.ruby-lang.org/en/) ([#176]).
* [`ruby-standard`](https://github.com/standardrb/standard) for
[ruby](https://www.ruby-lang.org/en/) ([#201])
+* [`ruff`](https://github.com/astral-sh/ruff) for
+ [python](https://python.org) ([#236])
* [`rufo`](https://github.com/ruby-formatter/rufo) for
[Ruby](https://www.ruby-lang.org/en/) ([#177]).
* [`yapf`](https://github.com/google/yapf) for [Python](https://www.python.org/) ([#196])
@@ -94,6 +96,7 @@ The format is based on [Keep a Changelog].
[#215]: https://github.com/radian-software/apheleia/pull/215
[#223]: https://github.com/radian-software/apheleia/pull/223
[#231]: https://github.com/radian-software/apheleia/pull/231
+[#236]: https://github.com/radian-software/apheleia/pull/236
## 3.2 (released 2023-02-25)
### Features
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index 84aa516..7fee4b7 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -121,6 +121,11 @@
"--stderr" "--format" "quiet" "--fail-level" "fatal"))
(ruby-standard . ("standardrb" "--stdin" filepath "--fix" "--stderr"
"--format" "quiet" "--fail-level" "fatal"))
+ (ruff . ("ruff" "format"
+ "--silent"
+ (apheleia-formatters-fill-column "--line-length")
+ "--stdin-filename" filepath
+ "-"))
(shfmt . ("shfmt"
"-filename" filepath
"-ln" (cl-case (bound-and-true-p sh-shell)
diff --git a/test/formatters/installers/ruff.bash b/test/formatters/installers/ruff.bash
new file mode 100644
index 0000000..9f5bf1a
--- /dev/null
+++ b/test/formatters/installers/ruff.bash
@@ -0,0 +1,2 @@
+apt-get install -y python3-pip
+pip install ruff
diff --git a/test/formatters/samplecode/ruff/in.py b/test/formatters/samplecode/ruff/in.py
new file mode 100644
index 0000000..21cdcdb
--- /dev/null
+++ b/test/formatters/samplecode/ruff/in.py
@@ -0,0 +1,4 @@
+def asdjf ( l,
+ a):
+ 3
+ +4
diff --git a/test/formatters/samplecode/ruff/out.py b/test/formatters/samplecode/ruff/out.py
new file mode 100644
index 0000000..0a63d13
--- /dev/null
+++ b/test/formatters/samplecode/ruff/out.py
@@ -0,0 +1,3 @@
+def asdjf(l, a):
+ 3
+ +4