-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: update fmt scripts to use black with jupyter ext #7342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,14 +87,23 @@ if (( only_changed == 1 )); then | |
else | ||
echo -e "Formatting all python files." >&2 | ||
IFS=$'\n' read -r -d '' -a format_files < \ | ||
<(git ls-files '*.py' ':(exclude)*_pb2.py') | ||
<(git ls-files '*.py' '*.ipynb' ':(exclude)*_pb2.py') | ||
fi | ||
|
||
if (( ${#format_files[@]} == 0 )); then | ||
echo -e "\033[32mNo files to format.\033[0m" | ||
exit 0 | ||
fi | ||
|
||
# Separate .py and .ipynb files | ||
for f in "${format_files[@]}"; do | ||
if [[ "${f}" == *.ipynb ]]; then | ||
format_ipynb_files+=("${f}") | ||
else | ||
format_py_files+=("${f}") | ||
fi | ||
done | ||
Comment on lines
+99
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to separate |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines 110-112 - the |
||
# Exclude __init__.py files from isort targets | ||
declare -a isort_files=() | ||
for f in "${format_files[@]}"; do | ||
|
@@ -133,8 +142,15 @@ if (( only_print == 1 )); then | |
args+=("--check" "--diff") | ||
fi | ||
|
||
black "${args[@]}" "${format_files[@]}" | ||
BLACKSTATUS=$? | ||
BLACKSTATUS=0 | ||
if (( "${#format_py_files[@]}" )); then | ||
black "${args[@]}" "${format_py_files[@]}" | ||
BLACKSTATUS=$? | ||
fi | ||
if (( "${#format_ipynb_files[@]}" )); then | ||
black "${args[@]}" --ipynb "${format_ipynb_files[@]}" | ||
BLACKSTATUS=$((BLACKSTATUS || $?)) | ||
fi | ||
Comment on lines
-136
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert back. It works OK if |
||
|
||
if (( BLACKSTATUS || ISORTSTATUS )); then | ||
exit 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
black==25.1.0 | ||
black[jupyter]==25.1.0 | ||
isort[colors]~=6.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if-branch above (lines 84-86) does not include
.ipynb
files. Please correct.