diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0fa4e8f64cc5..b45619a3234cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -142,6 +142,7 @@ repos: language: python types: [python] pass_filenames: false + additional_dependencies: [regex] # Keep `suggestion` last - id: suggestion name: Suggestion diff --git a/docs/mkdocs/hooks/generate_examples.py b/docs/mkdocs/hooks/generate_examples.py index c2f1f2d96f005..6f290efe45c2f 100644 --- a/docs/mkdocs/hooks/generate_examples.py +++ b/docs/mkdocs/hooks/generate_examples.py @@ -1,11 +1,11 @@ # SPDX-License-Identifier: Apache-2.0 - import itertools -import re from dataclasses import dataclass, field from pathlib import Path from typing import Literal +import regex as re + ROOT_DIR = Path(__file__).parent.parent.parent.parent ROOT_DIR_RELATIVE = '../../../../..' EXAMPLE_DIR = ROOT_DIR / "examples" diff --git a/docs/mkdocs/hooks/url_schemes.py b/docs/mkdocs/hooks/url_schemes.py index 03e7ffbb2733a..c738828085ba7 100644 --- a/docs/mkdocs/hooks/url_schemes.py +++ b/docs/mkdocs/hooks/url_schemes.py @@ -1,6 +1,5 @@ # SPDX-License-Identifier: Apache-2.0 -import re - +import regex as re from mkdocs.config.defaults import MkDocsConfig from mkdocs.structure.files import Files from mkdocs.structure.pages import Page diff --git a/requirements/docs.txt b/requirements/docs.txt index a1f51334ed81a..64c70cb65c550 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -5,4 +5,5 @@ mkdocstrings-python mkdocs-gen-files mkdocs-awesome-nav python-markdown-math +regex ruff diff --git a/tools/check_triton_import.py b/tools/check_triton_import.py index d938ff1df594b..18c9726a11ac0 100644 --- a/tools/check_triton_import.py +++ b/tools/check_triton_import.py @@ -1,8 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 -import re import subprocess import sys +import regex as re + FORBIDDEN_IMPORT_RE = re.compile(r"^(from|import)\s+triton(\s|\.|$)") # the way allowed to import triton diff --git a/vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py b/vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py index f483ac4eeee68..858c8db99fd29 100644 --- a/vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py +++ b/vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py @@ -1,11 +1,10 @@ # SPDX-License-Identifier: Apache-2.0 - import ast import json -import re from collections.abc import Sequence from typing import Any, Union +import regex as re from transformers import PreTrainedTokenizerBase from vllm.entrypoints.openai.protocol import (ChatCompletionRequest, diff --git a/vllm/model_executor/guided_decoding/guidance_decoding.py b/vllm/model_executor/guided_decoding/guidance_decoding.py index 0b1f4762bc730..58adcc3caff99 100644 --- a/vllm/model_executor/guided_decoding/guidance_decoding.py +++ b/vllm/model_executor/guided_decoding/guidance_decoding.py @@ -1,8 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 import json -from re import escape as regex_escape import llguidance +from regex import escape as regex_escape from transformers import PreTrainedTokenizerBase from vllm.model_executor.guided_decoding.guidance_logits_processors import ( diff --git a/vllm/model_executor/guided_decoding/outlines_decoding.py b/vllm/model_executor/guided_decoding/outlines_decoding.py index bcd7494e6cec2..e41af4b360e45 100644 --- a/vllm/model_executor/guided_decoding/outlines_decoding.py +++ b/vllm/model_executor/guided_decoding/outlines_decoding.py @@ -5,9 +5,9 @@ import concurrent.futures import os from enum import Enum from json import dumps as json_dumps -from re import escape as regex_escape from typing import Optional, Union +from regex import escape as regex_escape from transformers import PreTrainedTokenizerBase from vllm.model_executor.guided_decoding.outlines_logits_processors import (