Fix code formatting and linting issues
- Updated GitHub Actions workflow to use correct flake8 configuration - Fixed line length issues by using 88 characters as configured - Removed unused imports and trailing whitespace - Fixed f-string placeholders and unused variables - All linting checks now pass with project configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Base endpoint class for wikijs-python-sdk."""
|
||||
|
||||
from typing import Any, Dict, List, Optional, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client import WikiJSClient
|
||||
@@ -8,39 +8,39 @@ if TYPE_CHECKING:
|
||||
|
||||
class BaseEndpoint:
|
||||
"""Base class for all API endpoints.
|
||||
|
||||
|
||||
This class provides common functionality for making API requests
|
||||
and handling responses across all endpoint implementations.
|
||||
|
||||
|
||||
Args:
|
||||
client: The WikiJS client instance
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, client: "WikiJSClient"):
|
||||
"""Initialize endpoint with client reference.
|
||||
|
||||
|
||||
Args:
|
||||
client: WikiJS client instance
|
||||
"""
|
||||
self._client = client
|
||||
|
||||
|
||||
def _request(
|
||||
self,
|
||||
method: str,
|
||||
endpoint: str,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
) -> Dict[str, Any]:
|
||||
"""Make HTTP request through the client.
|
||||
|
||||
|
||||
Args:
|
||||
method: HTTP method (GET, POST, PUT, DELETE)
|
||||
endpoint: API endpoint path
|
||||
params: Query parameters
|
||||
json_data: JSON data for request body
|
||||
**kwargs: Additional request parameters
|
||||
|
||||
|
||||
Returns:
|
||||
Parsed response data
|
||||
"""
|
||||
@@ -49,94 +49,92 @@ class BaseEndpoint:
|
||||
endpoint=endpoint,
|
||||
params=params,
|
||||
json_data=json_data,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
def _get(
|
||||
self,
|
||||
endpoint: str,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
**kwargs
|
||||
self, endpoint: str, params: Optional[Dict[str, Any]] = None, **kwargs
|
||||
) -> Dict[str, Any]:
|
||||
"""Make GET request.
|
||||
|
||||
|
||||
Args:
|
||||
endpoint: API endpoint path
|
||||
params: Query parameters
|
||||
**kwargs: Additional request parameters
|
||||
|
||||
|
||||
Returns:
|
||||
Parsed response data
|
||||
"""
|
||||
return self._request("GET", endpoint, params=params, **kwargs)
|
||||
|
||||
|
||||
def _post(
|
||||
self,
|
||||
endpoint: str,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
) -> Dict[str, Any]:
|
||||
"""Make POST request.
|
||||
|
||||
|
||||
Args:
|
||||
endpoint: API endpoint path
|
||||
json_data: JSON data for request body
|
||||
params: Query parameters
|
||||
**kwargs: Additional request parameters
|
||||
|
||||
|
||||
Returns:
|
||||
Parsed response data
|
||||
"""
|
||||
return self._request("POST", endpoint, params=params, json_data=json_data, **kwargs)
|
||||
|
||||
return self._request(
|
||||
"POST", endpoint, params=params, json_data=json_data, **kwargs
|
||||
)
|
||||
|
||||
def _put(
|
||||
self,
|
||||
endpoint: str,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
) -> Dict[str, Any]:
|
||||
"""Make PUT request.
|
||||
|
||||
|
||||
Args:
|
||||
endpoint: API endpoint path
|
||||
json_data: JSON data for request body
|
||||
params: Query parameters
|
||||
**kwargs: Additional request parameters
|
||||
|
||||
|
||||
Returns:
|
||||
Parsed response data
|
||||
"""
|
||||
return self._request("PUT", endpoint, params=params, json_data=json_data, **kwargs)
|
||||
|
||||
return self._request(
|
||||
"PUT", endpoint, params=params, json_data=json_data, **kwargs
|
||||
)
|
||||
|
||||
def _delete(
|
||||
self,
|
||||
endpoint: str,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
**kwargs
|
||||
self, endpoint: str, params: Optional[Dict[str, Any]] = None, **kwargs
|
||||
) -> Dict[str, Any]:
|
||||
"""Make DELETE request.
|
||||
|
||||
|
||||
Args:
|
||||
endpoint: API endpoint path
|
||||
params: Query parameters
|
||||
**kwargs: Additional request parameters
|
||||
|
||||
|
||||
Returns:
|
||||
Parsed response data
|
||||
"""
|
||||
return self._request("DELETE", endpoint, params=params, **kwargs)
|
||||
|
||||
|
||||
def _build_endpoint(self, *parts: str) -> str:
|
||||
"""Build endpoint path from parts.
|
||||
|
||||
|
||||
Args:
|
||||
*parts: Path components
|
||||
|
||||
|
||||
Returns:
|
||||
Formatted endpoint path
|
||||
"""
|
||||
# Remove empty parts and join with /
|
||||
clean_parts = [str(part).strip("/") for part in parts if part]
|
||||
return "/" + "/".join(clean_parts)
|
||||
return "/" + "/".join(clean_parts)
|
||||
|
||||
Reference in New Issue
Block a user