code quality improvements

This commit is contained in:
SwiftyOS
2025-03-02 17:30:17 +01:00
committed by Swifty
parent 19728ebc05
commit 98a1adc397
2 changed files with 8 additions and 14 deletions

View File

@@ -20,13 +20,6 @@ class ExampleAPIException(Exception):
self.status_code = status_code
def _get_headers(credentials: APIKeyCredentials) -> dict[str, str]:
return {
"Authorization": credentials.api_key.get_secret_value(),
"Content-Type": "application/json",
}
class ExampleClient:
"""Client for the Example API"""
@@ -52,7 +45,8 @@ class ExampleClient:
raise_for_status=False,
)
def _handle_response(self, response) -> Any:
@staticmethod
def _handle_response(response) -> Any:
"""
Handles API response and checks for errors.

View File

@@ -99,20 +99,20 @@ class ExampleBlock(Block):
)
@staticmethod
def my_static_method(input: str) -> str:
logger.info("my_static_method called with input: %s", input)
return f"Hello, {input}!"
def my_static_method(post_greeting: str) -> str:
logger.info("my_static_method called with input: %s", post_greeting)
return f"Hello, {post_greeting}!"
def my_function_that_can_be_mocked(
self, input: str, credentials: APIKeyCredentials
self, name: str, credentials: APIKeyCredentials
) -> str:
logger.info("my_function_that_can_be_mocked called with input: %s", input)
logger.info("my_function_that_can_be_mocked called with input: %s", name)
# Use the ExampleClient from _api.py to make an API call
client = ExampleClient(credentials=credentials)
# Create a sample resource using the client
resource_data = {"name": input, "type": "greeting"}
resource_data = {"name": name, "type": "greeting"}
response = client.create_resource(resource_data)
return f"API response: {response.get('message', 'Hello, world!')}"