Skip to content
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

STY: Enable shellcheck pre-commit hook #60817

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ repos:
hooks:
- id: meson-fmt
args: ['--inplace']
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: ["--severity=warning"]
- repo: local
hooks:
- id: pyright
Expand Down
18 changes: 9 additions & 9 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ else
fi

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

BASE_DIR="$(dirname $0)/.."
BASE_DIR="$(dirname "$0")/.."
RET=0

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

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

fi

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

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

fi

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

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

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

fi
Expand Down
8 changes: 3 additions & 5 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# Workaround for pytest-xdist (it collects different tests in the workers if PYTHONHASHSEED is not set)
# https://github.com/pytest-dev/pytest/issues/920
# https://github.com/pytest-dev/pytest/issues/1075
export PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')

# May help reproduce flaky CI builds if set in subsequent runs
echo PYTHONHASHSEED=$PYTHONHASHSEED
PYTHONHASHSEED=$(python -c 'import random; print(random.randint(1, 4294967295))')
export PYTHONHASHSEED

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

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

echo $PYTEST_CMD
echo "$PYTEST_CMD"
sh -c "$PYTEST_CMD"
9 changes: 5 additions & 4 deletions ci/upload_wheels.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# Modified from numpy's https://github.com/numpy/numpy/blob/main/tools/wheels/upload_wheels.sh

set_upload_vars() {
Expand All @@ -19,20 +20,20 @@ set_upload_vars() {
fi
}
upload_wheels() {
echo ${PWD}
echo "${PWD}"
if [[ ${ANACONDA_UPLOAD} == true ]]; then
if [ -z ${TOKEN} ]; then
if [ -z "${TOKEN}" ]; then
echo no token set, not uploading
else
# sdists are located under dist folder when built through setup.py
if compgen -G "./dist/*.gz"; then
echo "Found sdist"
anaconda -q -t ${TOKEN} upload --skip -u ${ANACONDA_ORG} ./dist/*.gz
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./dist/*.gz
echo "Uploaded sdist"
fi
if compgen -G "./wheelhouse/*.whl"; then
echo "Found wheel"
anaconda -q -t ${TOKEN} upload --skip -u ${ANACONDA_ORG} ./wheelhouse/*.whl
anaconda -q -t "${TOKEN}" upload --skip -u "${ANACONDA_ORG}" ./wheelhouse/*.whl
echo "Uploaded wheel"
fi
echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"
Expand Down
1 change: 1 addition & 0 deletions scripts/cibw_before_build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# Add 3rd party licenses, like numpy does
for file in $PACKAGE_DIR/LICENSES/*; do
cat $file >> $PACKAGE_DIR/LICENSE
Expand Down
1 change: 1 addition & 0 deletions scripts/cibw_before_build_windows.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# Add 3rd party licenses, like numpy does
for file in $PACKAGE_DIR/LICENSES/*; do
cat $file >> $PACKAGE_DIR/LICENSE
Expand Down
1 change: 1 addition & 0 deletions scripts/cibw_before_test_windows.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# TODO: Delete when there's a NumPy Windows wheel for the free-threaded build on PyPI.
FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
if [[ $FREE_THREADED_BUILD == "True" ]]; then
Expand Down
17 changes: 9 additions & 8 deletions scripts/download_wheels.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Download all wheels for a pandas version.
#
Expand All @@ -11,19 +11,20 @@
# one by one to the dist/ directory where they would be generated.

VERSION=$1
mkdir -p $(dirname -- $0)/../dist
DIST_DIR="$(realpath $(dirname -- $0)/../dist)"
BASE_DIR=$(dirname -- $0)
mkdir -p $BASE_DIR/../dist
DIST_DIR="$(realpath $BASE_DIR/../dist)"

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

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

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