Skip to content

Commit 98a5083

Browse files
committed
Convert to spaces
1 parent f8ae67d commit 98a5083

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

scripts/format.sh

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,81 +9,81 @@ RUFF_UNSAFE_FIXES_FLAG=""
99

1010
# Process command-line arguments
1111
while [[ "$#" -gt 0 ]]; do
12-
case "$1" in
13-
--all)
14-
FORMAT_ALL=true
15-
echo "Detected --all flag: Formatting all tracked Python files."
16-
shift # Consume the argument
17-
;;
18-
--unsafe-fixes)
19-
RUFF_UNSAFE_FIXES_FLAG="--unsafe-fixes"
20-
echo "Detected --unsafe-fixes flag: Ruff will run with unsafe fixes."
21-
shift # Consume the argument
22-
;;
23-
*)
24-
# Handle unknown arguments or just ignore them
25-
echo "Warning: Unknown argument '$1'. Ignoring."
26-
shift # Consume the argument
27-
;;
28-
esac
12+
case "$1" in
13+
--all)
14+
FORMAT_ALL=true
15+
echo "Detected --all flag: Formatting all tracked Python files."
16+
shift # Consume the argument
17+
;;
18+
--unsafe-fixes)
19+
RUFF_UNSAFE_FIXES_FLAG="--unsafe-fixes"
20+
echo "Detected --unsafe-fixes flag: Ruff will run with unsafe fixes."
21+
shift # Consume the argument
22+
;;
23+
*)
24+
# Handle unknown arguments or just ignore them
25+
echo "Warning: Unknown argument '$1'. Ignoring."
26+
shift # Consume the argument
27+
;;
28+
esac
2929
done
3030

3131
# Sort Spelling Allowlist
3232
SPELLING_ALLOW_FILE=".github/actions/spelling/allow.txt"
3333
if [ -f "$SPELLING_ALLOW_FILE" ]; then
34-
echo "Sorting and de-duplicating $SPELLING_ALLOW_FILE"
35-
sort -u "$SPELLING_ALLOW_FILE" -o "$SPELLING_ALLOW_FILE"
34+
echo "Sorting and de-duplicating $SPELLING_ALLOW_FILE"
35+
sort -u "$SPELLING_ALLOW_FILE" -o "$SPELLING_ALLOW_FILE"
3636
fi
3737

3838
CHANGED_FILES=""
3939

4040
if $FORMAT_ALL; then
41-
echo "Finding all tracked Python files in the repository..."
42-
CHANGED_FILES=$(git ls-files -- '*.py' ':!src/a2a/grpc/*')
41+
echo "Finding all tracked Python files in the repository..."
42+
CHANGED_FILES=$(git ls-files -- '*.py' ':!src/a2a/grpc/*')
4343
else
44-
echo "Finding changed Python files based on git diff..."
45-
TARGET_BRANCH="origin/${GITHUB_BASE_REF:-main}"
46-
git fetch origin "${GITHUB_BASE_REF:-main}" --depth=1
44+
echo "Finding changed Python files based on git diff..."
45+
TARGET_BRANCH="origin/${GITHUB_BASE_REF:-main}"
46+
git fetch origin "${GITHUB_BASE_REF:-main}" --depth=1
4747

48-
MERGE_BASE=$(git merge-base HEAD "$TARGET_BRANCH")
48+
MERGE_BASE=$(git merge-base HEAD "$TARGET_BRANCH")
4949

50-
# Get python files changed in this PR, excluding grpc generated files.
51-
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$MERGE_BASE" HEAD -- '*.py' ':!src/a2a/grpc/*')
50+
# Get python files changed in this PR, excluding grpc generated files.
51+
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$MERGE_BASE" HEAD -- '*.py' ':!src/a2a/grpc/*')
5252
fi
5353

5454
# Exit if no files were found
5555
if [ -z "$CHANGED_FILES" ]; then
56-
echo "No changed or tracked Python files to format."
57-
exit 0
56+
echo "No changed or tracked Python files to format."
57+
exit 0
5858
fi
5959

6060
# --- Helper Function ---
6161
# Runs a command on a list of files passed via stdin.
6262
# $1: A string containing the list of files (space-separated).
6363
# $2...: The command and its arguments to run.
6464
run_formatter() {
65-
local files_to_format="$1"
66-
shift # Remove the file list from the arguments
67-
if [ -n "$files_to_format" ]; then
68-
echo "$files_to_format" | xargs -r "$@"
69-
fi
65+
local files_to_format="$1"
66+
shift # Remove the file list from the arguments
67+
if [ -n "$files_to_format" ]; then
68+
echo "$files_to_format" | xargs -r "$@"
69+
fi
7070
}
7171

7272
# --- Python File Formatting ---
7373
if [ -n "$CHANGED_FILES" ]; then
74-
echo "--- Formatting Python Files ---"
75-
echo "Files to be formatted:"
76-
echo "$CHANGED_FILES"
74+
echo "--- Formatting Python Files ---"
75+
echo "Files to be formatted:"
76+
echo "$CHANGED_FILES"
7777

78-
echo "Running autoflake..."
79-
run_formatter "$CHANGED_FILES" autoflake -i -r --remove-all-unused-imports
80-
echo "Running ruff check (fix-only)..."
81-
run_formatter "$CHANGED_FILES" ruff check --fix-only $RUFF_UNSAFE_FIXES_FLAG
82-
echo "Running ruff format..."
83-
run_formatter "$CHANGED_FILES" ruff format
84-
echo "Python formatting complete."
78+
echo "Running autoflake..."
79+
run_formatter "$CHANGED_FILES" autoflake -i -r --remove-all-unused-imports
80+
echo "Running ruff check (fix-only)..."
81+
run_formatter "$CHANGED_FILES" ruff check --fix-only $RUFF_UNSAFE_FIXES_FLAG
82+
echo "Running ruff format..."
83+
run_formatter "$CHANGED_FILES" ruff format
84+
echo "Python formatting complete."
8585
else
86-
echo "No Python files to format."
86+
echo "No Python files to format."
8787
fi
8888

8989
echo "All formatting tasks are complete."

0 commit comments

Comments
 (0)