Fix test failures and formatting issues
- Fixed black formatting in exceptions.py - Restored parse_wiki_response to original behavior (return input unchanged for non-dict) - Enhanced validate_url to properly reject URLs with spaces - Fixed 3 previously failing utility tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,9 @@ class PermissionError(ClientError):
|
|||||||
class RateLimitError(ClientError):
|
class RateLimitError(ClientError):
|
||||||
"""Raised when rate limit is exceeded (429)."""
|
"""Raised when rate limit is exceeded (429)."""
|
||||||
|
|
||||||
def __init__(self, message: str, retry_after: Optional[int] = None, **kwargs: Any) -> None:
|
def __init__(
|
||||||
|
self, message: str, retry_after: Optional[int] = None, **kwargs: Any
|
||||||
|
) -> None:
|
||||||
# Remove status_code from kwargs if present to avoid duplicate argument
|
# Remove status_code from kwargs if present to avoid duplicate argument
|
||||||
kwargs.pop("status_code", None)
|
kwargs.pop("status_code", None)
|
||||||
super().__init__(message, status_code=429, **kwargs)
|
super().__init__(message, status_code=429, **kwargs)
|
||||||
|
|||||||
@@ -45,7 +45,15 @@ def validate_url(url: str) -> bool:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
result = urlparse(url)
|
result = urlparse(url)
|
||||||
return all([result.scheme, result.netloc])
|
# Check basic components exist
|
||||||
|
if not all([result.scheme, result.netloc]):
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check for invalid characters (spaces, etc.)
|
||||||
|
if " " in url:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -103,7 +111,7 @@ def build_api_url(base_url: str, endpoint: str) -> str:
|
|||||||
return urljoin(api_base, endpoint.lstrip("/"))
|
return urljoin(api_base, endpoint.lstrip("/"))
|
||||||
|
|
||||||
|
|
||||||
def parse_wiki_response(response_data: Any) -> Dict[str, Any]:
|
def parse_wiki_response(response_data: Any) -> Any:
|
||||||
"""Parse Wiki.js API response data.
|
"""Parse Wiki.js API response data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -116,7 +124,7 @@ def parse_wiki_response(response_data: Any) -> Dict[str, Any]:
|
|||||||
APIError: If response indicates an error
|
APIError: If response indicates an error
|
||||||
"""
|
"""
|
||||||
if not isinstance(response_data, dict):
|
if not isinstance(response_data, dict):
|
||||||
return {"data": response_data}
|
return response_data
|
||||||
|
|
||||||
# Check for error indicators
|
# Check for error indicators
|
||||||
if "error" in response_data:
|
if "error" in response_data:
|
||||||
|
|||||||
Reference in New Issue
Block a user