Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -1,7 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""
|
||||
Access log filter for uvicorn to exclude specific endpoints from logging.
|
||||
"""Access log filter for uvicorn to exclude specific endpoints from logging.
|
||||
|
||||
This module provides a logging filter that can be used to suppress access logs
|
||||
for specific endpoints (e.g., /health, /metrics) to reduce log noise in
|
||||
@@ -13,8 +12,7 @@ from urllib.parse import urlparse
|
||||
|
||||
|
||||
class UvicornAccessLogFilter(logging.Filter):
|
||||
"""
|
||||
A logging filter that excludes access logs for specified endpoint paths.
|
||||
"""A logging filter that excludes access logs for specified endpoint paths.
|
||||
|
||||
This filter is designed to work with uvicorn's access logger. It checks
|
||||
the log record's arguments for the request path and filters out records
|
||||
@@ -31,6 +29,7 @@ class UvicornAccessLogFilter(logging.Filter):
|
||||
excluded_paths: A list of URL paths to exclude from logging.
|
||||
Paths are matched exactly.
|
||||
Example: ["/health", "/metrics"]
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, excluded_paths: list[str] | None = None):
|
||||
@@ -38,14 +37,14 @@ class UvicornAccessLogFilter(logging.Filter):
|
||||
self.excluded_paths = set(excluded_paths or [])
|
||||
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
"""
|
||||
Determine if the log record should be logged.
|
||||
"""Determine if the log record should be logged.
|
||||
|
||||
Args:
|
||||
record: The log record to evaluate.
|
||||
|
||||
Returns:
|
||||
True if the record should be logged, False otherwise.
|
||||
|
||||
"""
|
||||
if not self.excluded_paths:
|
||||
return True
|
||||
@@ -72,8 +71,7 @@ def create_uvicorn_log_config(
|
||||
excluded_paths: list[str] | None = None,
|
||||
log_level: str = "info",
|
||||
) -> dict:
|
||||
"""
|
||||
Create a uvicorn logging configuration with access log filtering.
|
||||
"""Create a uvicorn logging configuration with access log filtering.
|
||||
|
||||
This function generates a logging configuration dictionary that can be
|
||||
passed to uvicorn's `log_config` parameter. It sets up the access log
|
||||
@@ -89,6 +87,7 @@ def create_uvicorn_log_config(
|
||||
Example:
|
||||
>>> config = create_uvicorn_log_config(["/health", "/metrics"])
|
||||
>>> uvicorn.run(app, log_config=config)
|
||||
|
||||
"""
|
||||
config = {
|
||||
"version": 1,
|
||||
|
||||
@@ -19,8 +19,7 @@ class NewLineFormatter(logging.Formatter):
|
||||
|
||||
def format(self, record):
|
||||
def shrink_path(relpath: Path) -> str:
|
||||
"""
|
||||
Shortens a file path for logging display:
|
||||
"""Shortens a file path for logging display:
|
||||
- Removes leading 'vllm' folder if present.
|
||||
- If path starts with 'v1',
|
||||
keeps the first two and last two levels,
|
||||
@@ -36,8 +35,10 @@ class NewLineFormatter(logging.Formatter):
|
||||
|
||||
Args:
|
||||
relpath (Path): The relative path to be shortened.
|
||||
|
||||
Returns:
|
||||
str: The shortened path string for display.
|
||||
|
||||
"""
|
||||
parts = list(relpath.parts)
|
||||
new_parts = []
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""
|
||||
Provides a timeslice logging decorator
|
||||
"""
|
||||
"""Provides a timeslice logging decorator."""
|
||||
|
||||
import functools
|
||||
import time
|
||||
|
||||
|
||||
def logtime(logger, msg=None):
|
||||
"""
|
||||
Logs the execution time of the decorated function.
|
||||
"""Logs the execution time of the decorated function.
|
||||
Always place it beneath other decorators.
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user