-
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?
feat: update fmt scripts to use black with jupyter ext #7342
Conversation
The tests were failing because I passed the 🐕 ❯ pytest -p no:warnings dev_tools/bash_scripts_test.py::test_incremental_format_branch_selection
=============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.11.11, pytest-8.3.5, pluggy-1.5.0
rootdir: /Users/sauravmaheshkar/dev/Cirq
configfile: pyproject.toml
collected 1 item
dev_tools/bash_scripts_test.py . [100%]
================================================================================ 1 passed in 3.83s ================================================================================ |
a49cdcd
to
74b272e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7342 +/- ##
==========================================
- Coverage 98.67% 98.67% -0.01%
==========================================
Files 1112 1112
Lines 97038 97038
==========================================
- Hits 95757 95755 -2
- Misses 1281 1283 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -87,14 +87,23 @@ if (( only_changed == 1 )); then | |||
else |
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.
for f in "${format_files[@]}"; do | ||
if [[ "${f}" == *.ipynb ]]; then | ||
format_ipynb_files+=("${f}") | ||
else | ||
format_py_files+=("${f}") | ||
fi | ||
done |
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.
There is no need to separate .ipynb
and .py
files into two arrays.
Black can detect the file type of its arguments, just run it without the --ipynb
option.
format_py_files+=("${f}") | ||
fi | ||
done | ||
|
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.
Lines 110-112 - the isort_files
array would include .ipynb
files if they were in format_files
, but it should only contain .py
files. Please adjust the condition on line 110.
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 |
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.
Please revert back. It works OK if black
is run without the --ipynb
option.
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 default operation of this script is to check formatting of files that changed w/r to the main
branch. This currently does not detect .ipynb
files, please correct.
Also, please see inline comments for more suggestions.
Following up from #7256
This is the 1st PR updating the scripts and the requirements. Follow up PR with the actual changes will follow.
CC: @pavoljuhas
Output