Convert formatting to use ruff instead of yapf + isort (#26247)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -17,44 +17,48 @@ import regex as re
|
||||
# add to this list if absolutely necessary and after careful security review.
|
||||
ALLOWED_FILES = {
|
||||
# pickle
|
||||
'vllm/v1/serial_utils.py',
|
||||
'vllm/v1/executor/multiproc_executor.py',
|
||||
'vllm/multimodal/hasher.py',
|
||||
'vllm/transformers_utils/config.py',
|
||||
'vllm/model_executor/models/registry.py',
|
||||
'tests/utils_/test_utils.py',
|
||||
'tests/tokenization/test_cached_tokenizer.py',
|
||||
'vllm/distributed/utils.py',
|
||||
'vllm/distributed/parallel_state.py',
|
||||
'vllm/distributed/device_communicators/all_reduce_utils.py',
|
||||
'vllm/distributed/device_communicators/shm_broadcast.py',
|
||||
'vllm/distributed/device_communicators/shm_object_storage.py',
|
||||
'benchmarks/kernels/graph_machete_bench.py',
|
||||
'benchmarks/kernels/benchmark_lora.py',
|
||||
'benchmarks/kernels/benchmark_machete.py',
|
||||
'benchmarks/fused_kernels/layernorm_rms_benchmarks.py',
|
||||
'benchmarks/cutlass_benchmarks/w8a8_benchmarks.py',
|
||||
'benchmarks/cutlass_benchmarks/sparse_benchmarks.py',
|
||||
"vllm/v1/serial_utils.py",
|
||||
"vllm/v1/executor/multiproc_executor.py",
|
||||
"vllm/multimodal/hasher.py",
|
||||
"vllm/transformers_utils/config.py",
|
||||
"vllm/model_executor/models/registry.py",
|
||||
"tests/utils_/test_utils.py",
|
||||
"tests/tokenization/test_cached_tokenizer.py",
|
||||
"vllm/distributed/utils.py",
|
||||
"vllm/distributed/parallel_state.py",
|
||||
"vllm/distributed/device_communicators/all_reduce_utils.py",
|
||||
"vllm/distributed/device_communicators/shm_broadcast.py",
|
||||
"vllm/distributed/device_communicators/shm_object_storage.py",
|
||||
"benchmarks/kernels/graph_machete_bench.py",
|
||||
"benchmarks/kernels/benchmark_lora.py",
|
||||
"benchmarks/kernels/benchmark_machete.py",
|
||||
"benchmarks/fused_kernels/layernorm_rms_benchmarks.py",
|
||||
"benchmarks/cutlass_benchmarks/w8a8_benchmarks.py",
|
||||
"benchmarks/cutlass_benchmarks/sparse_benchmarks.py",
|
||||
# cloudpickle
|
||||
'vllm/executor/mp_distributed_executor.py',
|
||||
'vllm/executor/ray_distributed_executor.py',
|
||||
'vllm/entrypoints/llm.py',
|
||||
'tests/utils.py',
|
||||
"vllm/executor/mp_distributed_executor.py",
|
||||
"vllm/executor/ray_distributed_executor.py",
|
||||
"vllm/entrypoints/llm.py",
|
||||
"tests/utils.py",
|
||||
# pickle and cloudpickle
|
||||
'vllm/utils/__init__.py',
|
||||
"vllm/utils/__init__.py",
|
||||
}
|
||||
|
||||
PICKLE_RE = re.compile(r"^\s*(import\s+(pickle|cloudpickle)(\s|$|\sas)"
|
||||
r"|from\s+(pickle|cloudpickle)\s+import\b)")
|
||||
PICKLE_RE = re.compile(
|
||||
r"^\s*(import\s+(pickle|cloudpickle)(\s|$|\sas)"
|
||||
r"|from\s+(pickle|cloudpickle)\s+import\b)"
|
||||
)
|
||||
|
||||
|
||||
def scan_file(path: str) -> int:
|
||||
with open(path, encoding='utf-8') as f:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
for i, line in enumerate(f, 1):
|
||||
if PICKLE_RE.match(line):
|
||||
print(f"{path}:{i}: "
|
||||
"\033[91merror:\033[0m " # red color
|
||||
"Found pickle/cloudpickle import")
|
||||
print(
|
||||
f"{path}:{i}: "
|
||||
"\033[91merror:\033[0m " # red color
|
||||
"Found pickle/cloudpickle import"
|
||||
)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -92,13 +96,13 @@ def test_regex():
|
||||
for i, (line, should_match) in enumerate(test_cases):
|
||||
result = bool(PICKLE_RE.match(line))
|
||||
assert result == should_match, (
|
||||
f"Test case {i} failed: '{line}' "
|
||||
f"(expected {should_match}, got {result})")
|
||||
f"Test case {i} failed: '{line}' (expected {should_match}, got {result})"
|
||||
)
|
||||
print("All regex tests passed.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if '--test-regex' in sys.argv:
|
||||
if __name__ == "__main__":
|
||||
if "--test-regex" in sys.argv:
|
||||
test_regex()
|
||||
else:
|
||||
sys.exit(main())
|
||||
|
||||
@@ -94,11 +94,15 @@ def group_files(changed_files: list[str]) -> dict[str, list[str]]:
|
||||
return file_groups
|
||||
|
||||
|
||||
def mypy(targets: list[str], python_version: Optional[str],
|
||||
follow_imports: Optional[str], file_group: str) -> int:
|
||||
def mypy(
|
||||
targets: list[str],
|
||||
python_version: Optional[str],
|
||||
follow_imports: Optional[str],
|
||||
file_group: str,
|
||||
) -> int:
|
||||
"""
|
||||
Run mypy on the given targets.
|
||||
|
||||
|
||||
Args:
|
||||
targets: List of files or directories to check.
|
||||
python_version: Python version to use (e.g., "3.10") or None to use
|
||||
@@ -131,8 +135,9 @@ def main():
|
||||
for file_group, changed_files in file_groups.items():
|
||||
follow_imports = None if ci and file_group == "" else "skip"
|
||||
if changed_files:
|
||||
returncode |= mypy(changed_files, python_version, follow_imports,
|
||||
file_group)
|
||||
returncode |= mypy(
|
||||
changed_files, python_version, follow_imports, file_group
|
||||
)
|
||||
return returncode
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user