Skip to content

Commit 02de814

Browse files
authored
STY: Enable shellcheck pre-commit hook (#60817)
1 parent 5e5da07 commit 02de814

8 files changed

+34
-26
lines changed

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ repos:
106106
hooks:
107107
- id: meson-fmt
108108
args: ['--inplace']
109+
- repo: https://github.com/shellcheck-py/shellcheck-py
110+
rev: v0.10.0.1
111+
hooks:
112+
- id: shellcheck
113+
args: ["--severity=warning"]
109114
- repo: local
110115
hooks:
111116
- id: pyright

ci/code_checks.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ else
2424
fi
2525

2626
[[ -z "$CHECK" || "$CHECK" == "code" || "$CHECK" == "doctests" || "$CHECK" == "docstrings" || "$CHECK" == "single-docs" || "$CHECK" == "notebooks" ]] || \
27-
{ echo "Unknown command $1. Usage: $0 [code|doctests|docstrings|single-docs|notebooks]"; exit 9999; }
27+
{ echo "Unknown command $1. Usage: $0 [code|doctests|docstrings|single-docs|notebooks]"; exit 1; }
2828

29-
BASE_DIR="$(dirname $0)/.."
29+
BASE_DIR="$(dirname "$0")/.."
3030
RET=0
3131

3232
### CODE ###
3333
if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then
3434

35-
MSG='Check import. No warnings, and blocklist some optional dependencies' ; echo $MSG
35+
MSG='Check import. No warnings, and blocklist some optional dependencies' ; echo "$MSG"
3636
python -W error -c "
3737
import sys
3838
import pandas
@@ -49,24 +49,24 @@ if mods:
4949
sys.stderr.write('err: pandas should not import: {}\n'.format(', '.join(mods)))
5050
sys.exit(len(mods))
5151
"
52-
RET=$(($RET + $?)) ; echo $MSG "DONE"
52+
RET=$(($RET + $?)) ; echo "$MSG" "DONE"
5353

5454
fi
5555

5656
### DOCTESTS ###
5757
if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
5858

59-
MSG='Python and Cython Doctests' ; echo $MSG
59+
MSG='Python and Cython Doctests' ; echo "$MSG"
6060
python -c 'import pandas as pd; pd.test(run_doctests=True)'
61-
RET=$(($RET + $?)) ; echo $MSG "DONE"
61+
RET=$(($RET + $?)) ; echo "$MSG" "DONE"
6262

6363
fi
6464

6565
### DOCSTRINGS ###
6666
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6767

68-
MSG='Validate Docstrings' ; echo $MSG
69-
$BASE_DIR/scripts/validate_docstrings.py \
68+
MSG='Validate Docstrings' ; echo "$MSG"
69+
"$BASE_DIR"/scripts/validate_docstrings.py \
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
@@ -265,7 +265,7 @@ fi
265265
if [[ -z "$CHECK" || "$CHECK" == "notebooks" ]]; then
266266

267267
MSG='Notebooks' ; echo $MSG
268-
jupyter nbconvert --execute $(find doc/source -name '*.ipynb') --to notebook
268+
jupyter nbconvert --execute "$(find doc/source -name '*.ipynb')" --to notebook
269269
RET=$(($RET + $?)) ; echo $MSG "DONE"
270270

271271
fi

ci/run_tests.sh

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
# Workaround for pytest-xdist (it collects different tests in the workers if PYTHONHASHSEED is not set)
44
# https://github.com/pytest-dev/pytest/issues/920
55
# https://github.com/pytest-dev/pytest/issues/1075
6-
export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')
7-
8-
# May help reproduce flaky CI builds if set in subsequent runs
9-
echo PYTHONHASHSEED=$PYTHONHASHSEED
6+
PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')
7+
export PYTHONHASHSEED
108

119
COVERAGE="-s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml"
1210

@@ -16,5 +14,5 @@ if [[ "$PATTERN" ]]; then
1614
PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\""
1715
fi
1816

19-
echo $PYTEST_CMD
17+
echo "$PYTEST_CMD"
2018
sh -c "$PYTEST_CMD"

ci/upload_wheels.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# Modified from numpy's https://github.com/numpy/numpy/blob/main/tools/wheels/upload_wheels.sh
23

34
set_upload_vars() {
@@ -19,20 +20,20 @@ set_upload_vars() {
1920
fi
2021
}
2122
upload_wheels() {
22-
echo ${PWD}
23+
echo "${PWD}"
2324
if [[ ${ANACONDA_UPLOAD} == true ]]; then
24-
if [ -z ${TOKEN} ]; then
25+
if [ -z "${TOKEN}" ]; then
2526
echo no token set, not uploading
2627
else
2728
# sdists are located under dist folder when built through setup.py
2829
if compgen -G "./dist/*.gz"; then
2930
echo "Found sdist"
30-
anaconda -q -t ${TOKEN} upload --skip -u ${ANACONDA_ORG} ./dist/*.gz
31+
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./dist/*.gz
3132
echo "Uploaded sdist"
3233
fi
3334
if compgen -G "./wheelhouse/*.whl"; then
3435
echo "Found wheel"
35-
anaconda -q -t ${TOKEN} upload --skip -u ${ANACONDA_ORG} ./wheelhouse/*.whl
36+
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./wheelhouse/*.whl
3637
echo "Uploaded wheel"
3738
fi
3839
echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"

scripts/cibw_before_build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# Add 3rd party licenses, like numpy does
23
for file in $PACKAGE_DIR/LICENSES/*; do
34
cat $file >> $PACKAGE_DIR/LICENSE

scripts/cibw_before_build_windows.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# Add 3rd party licenses, like numpy does
23
for file in $PACKAGE_DIR/LICENSES/*; do
34
cat $file >> $PACKAGE_DIR/LICENSE

scripts/cibw_before_test_windows.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
# TODO: Delete when there's a NumPy Windows wheel for the free-threaded build on PyPI.
23
FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
34
if [[ $FREE_THREADED_BUILD == "True" ]]; then

scripts/download_wheels.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# Download all wheels for a pandas version.
44
#
@@ -11,19 +11,20 @@
1111
# one by one to the dist/ directory where they would be generated.
1212

1313
VERSION=$1
14-
mkdir -p $(dirname -- $0)/../dist
15-
DIST_DIR="$(realpath $(dirname -- $0)/../dist)"
14+
BASE_DIR=$(dirname -- $0)
15+
mkdir -p $BASE_DIR/../dist
16+
DIST_DIR="$(realpath $BASE_DIR/../dist)"
1617

17-
if [ -z $VERSION ]; then
18-
printf "Usage:\n\t$0 <version>\n\nWhere <version> is for example 1.5.3"
18+
if [ -z "$VERSION" ]; then
19+
printf "Usage:\n\t%s <version>\n\nWhere <version> is for example 1.5.3" "$0"
1920
exit 1
2021
fi
2122

2223
curl "https://anaconda.org/multibuild-wheels-staging/pandas/files?version=${VERSION}" | \
2324
grep "href=\"/multibuild-wheels-staging/pandas/${VERSION}" | \
2425
sed -r 's/.*<a href="([^"]+\.(whl|tar.gz))">.*/\1/g' | \
2526
awk '{print "https://anaconda.org" $0 }' | \
26-
xargs wget -P $DIST_DIR
27+
xargs wget -P "$DIST_DIR"
2728

28-
printf "\nWheels downloaded to $DIST_DIR\nYou can upload them to PyPI using:\n\n"
29-
printf "\ttwine upload ${DIST_DIR}/pandas-${VERSION}*.{whl,tar.gz} --skip-existing"
29+
printf '\nWheels downloaded to %s\nYou can upload them to PyPI using:\n\n' "$DIST_DIR"
30+
printf "\ttwine upload %s/pandas-%s*.{whl,tar.gz} --skip-existing" "$DIST_DIR" "$VERSION"

0 commit comments

Comments
 (0)