Skip to content

Commit 0f18f8b

Browse files
authored
Fix/10 add autoformat.sh script (#11)
* ci: add unit test workflow * fix: add missing autoformat.sh script * fix: update autoformat.sh script
1 parent 676d00f commit 0f18f8b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

autoformat.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
#
3+
# This script runs the auto-formatters (isort and pyink)
4+
# to fix code style and import order.
5+
6+
set -e
7+
8+
if ! command -v isort &> /dev/null
9+
then
10+
echo "isort not found, refer to CONTRIBUTING.md to set up dev environment first."
11+
exit
12+
fi
13+
14+
if ! command -v pyink &> /dev/null
15+
then
16+
echo "pyink not found, refer to CONTRIBUTING.md to set up dev environment first."
17+
exit
18+
fi
19+
20+
21+
echo '---------------------------------------'
22+
echo '| Organizing imports for src/...'
23+
echo '---------------------------------------'
24+
25+
isort src/
26+
echo 'All done! ✨ 🍰 ✨'
27+
28+
echo '---------------------------------------'
29+
echo '| Organizing imports for tests/...'
30+
echo '---------------------------------------'
31+
32+
isort tests/
33+
echo 'All done! ✨ 🍰 ✨'
34+
35+
36+
37+
echo '---------------------------------------'
38+
echo '| Auto-formatting src/...'
39+
echo '---------------------------------------'
40+
41+
find -L src/ -not -path "*/.*" -type f -name "*.py" -exec pyink --config pyproject.toml {} +
42+
43+
echo '---------------------------------------'
44+
echo '| Auto-formatting tests/...'
45+
echo '---------------------------------------'
46+
47+
find -L tests/ -not -path "*/.*" -type f -name "*.py" -exec pyink --config pyproject.toml {} +
48+
49+
50+
echo "Formatting complete."

0 commit comments

Comments
 (0)