fix: determine cpu cores determination in baseedpyright-check script on macos (#28058)

This commit is contained in:
Bowen Liang
2025-11-12 19:27:27 +08:00
committed by GitHub
parent b76e17b25d
commit 1369119a0c
2 changed files with 12 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import sys
def is_db_command():
def is_db_command() -> bool:
if len(sys.argv) > 1 and sys.argv[0].endswith("flask") and sys.argv[1] == "db":
return True
return False

View File

@@ -8,9 +8,14 @@ cd "$SCRIPT_DIR/.."
# Get the path argument if provided
PATH_TO_CHECK="$1"
# run basedpyright checks
if [ -n "$PATH_TO_CHECK" ]; then
uv run --directory api --dev -- basedpyright --threads $(nproc) "$PATH_TO_CHECK"
else
uv run --directory api --dev -- basedpyright --threads $(nproc)
fi
# Determine CPU core count based on OS
CPU_CORES=$(
if [[ "$(uname -s)" == "Darwin" ]]; then
sysctl -n hw.ncpu 2>/dev/null
else
nproc
fi
)
# Run basedpyright checks
uv run --directory api --dev -- basedpyright --threads "$CPU_CORES" $PATH_TO_CHECK