Skip to content

Commit 5816391

Browse files
committed
update format.sh and solve ruff errors
1 parent ff0092a commit 5816391

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

benchmarks/benchmark_serving.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def main(args: argparse.Namespace):
375375
parser.add_argument(
376376
"--disable-tqdm",
377377
action="store_true",
378-
help="Specify to disbale tqdm progress bar.",
378+
help="Specify to disable tqdm progress bar.",
379379
)
380380
parser.add_argument(
381381
"--save-result",

format.sh

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ builtin cd "$ROOT" || exit 1
2424
YAPF_VERSION=$(yapf --version | awk '{print $2}')
2525
RUFF_VERSION=$(ruff --version | awk '{print $2}')
2626
MYPY_VERSION=$(mypy --version | awk '{print $2}')
27+
CODESPELL_VERSION=$(codespell --version)
2728

2829
# # params: tool name, tool version, required version
2930
tool_version_check() {
@@ -36,6 +37,7 @@ tool_version_check() {
3637
tool_version_check "yapf" $YAPF_VERSION "$(grep yapf requirements-dev.txt | cut -d'=' -f3)"
3738
tool_version_check "ruff" $RUFF_VERSION "$(grep "ruff==" requirements-dev.txt | cut -d'=' -f3)"
3839
tool_version_check "mypy" "$MYPY_VERSION" "$(grep mypy requirements-dev.txt | cut -d'=' -f3)"
40+
tool_version_check "codespell" "$CODESPELL_VERSION" "$(grep codespell requirements-dev.txt | cut -d'=' -f3)"
3941

4042
YAPF_FLAGS=(
4143
'--recursive'
@@ -93,6 +95,47 @@ echo 'vLLM yapf: Done'
9395
# echo 'vLLM mypy:'
9496
# mypy
9597

98+
# check spelling of specified files
99+
spell_check() {
100+
codespell "$@"
101+
}
102+
103+
spell_check_all(){
104+
codespell --toml pyproject.toml
105+
}
106+
107+
# Spelling check of files that differ from main branch.
108+
spell_check_changed() {
109+
# The `if` guard ensures that the list of filenames is not empty, which
110+
# could cause ruff to receive 0 positional arguments, making it hang
111+
# waiting for STDIN.
112+
#
113+
# `diff-filter=ACM` and $MERGEBASE is to ensure we only lint files that
114+
# exist on both branches.
115+
MERGEBASE="$(git merge-base origin/main HEAD)"
116+
117+
if ! git diff --diff-filter=ACM --quiet --exit-code "$MERGEBASE" -- '*.py' '*.pyi' &>/dev/null; then
118+
git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.py' '*.pyi' | xargs \
119+
codespell
120+
fi
121+
}
122+
123+
# Run Codespell
124+
## This flag runs spell check of individual files. --files *must* be the first command line
125+
## arg to use this option.
126+
if [[ "$1" == '--files' ]]; then
127+
spell_check "${@:2}"
128+
# If `--all` is passed, then any further arguments are ignored and the
129+
# entire python directory is linted.
130+
elif [[ "$1" == '--all' ]]; then
131+
spell_check_all
132+
else
133+
# Check spelling only of the files that changed in last commit.
134+
spell_check_changed
135+
fi
136+
echo 'vLLM codespell: Done'
137+
138+
96139
# Lint specified files
97140
lint() {
98141
ruff "$@"
@@ -117,9 +160,9 @@ lint_changed() {
117160
}
118161

119162
# Run Ruff
120-
echo 'vLLM Ruff:'
121-
## This flag lints individual files. --files *must* be the first command line
122-
## arg to use this option.
163+
echo 'vLLM ruff:'
164+
### This flag lints individual files. --files *must* be the first command line
165+
### arg to use this option.
123166
if [[ "$1" == '--files' ]]; then
124167
lint "${@:2}"
125168
# If `--all` is passed, then any further arguments are ignored and the
@@ -139,3 +182,5 @@ if ! git diff --quiet &>/dev/null; then
139182

140183
exit 1
141184
fi
185+
186+

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ ignore = [
3131
"E731",
3232
# line too long, handled by black formatting
3333
"E501",
34+
# .strip() with multi-character strings
35+
"B005",
36+
# Loop control variable not used within loop body
37+
"B007",
3438
]
3539

3640
[tool.mypy]

vllm/lora/punica.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def add_lora(y: torch.Tensor,
8787
r = wb_t_all.size(-1)
8888
if buffer is None:
8989
# We set the buffer to be float32 by default to avoid
90-
# numerical innacuracies that would otherwise happen
90+
# numerical inaccuracies that would otherwise happen
9191
# due to downcasting.
9292
buffer = torch.zeros((x.size(0), r),
9393
dtype=torch.float32,

0 commit comments

Comments
 (0)