Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(server): various linting errors (#7498)

Nicholas Tindle057d0848ef8d
diff --git a/rnd/autogpt_server/autogpt_server/blocks/create_medium_post.py b/rnd/autogpt_server/autogpt_server/blocks/create_medium_post.py
index 157622a9a0..365fc966f4 100644
--- a/rnd/autogpt_server/autogpt_server/blocks/create_medium_post.py
+++ b/rnd/autogpt_server/autogpt_server/blocks/create_medium_post.py
@@ -8,7 +8,7 @@ from autogpt_server.data.model import BlockSecret, SchemaField, SecretField
class CreateMediumPostBlock(Block):
class Input(BlockSchema):
- author_id: str = SecretField(
+ author_id: BlockSecret = SecretField(
key="medium_author_id",
description="""The Medium AuthorID of the user. You can get this by calling the /me endpoint of the Medium API.\n\ncurl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://api.medium.com/v1/me" the response will contain the authorId field.""",
placeholder="Enter the author's Medium AuthorID",
@@ -29,7 +29,7 @@ class CreateMediumPostBlock(Block):
description="List of tags for your Medium post (up to 5)",
placeholder="['technology', 'AI', 'blogging']",
)
- canonical_url: str = SchemaField(
+ canonical_url: str | None = SchemaField(
default=None,
description="The original home of this content, if it was originally published elsewhere",
placeholder="https://yourblog.com/original-post",
diff --git a/rnd/autogpt_server/autogpt_server/blocks/search.py b/rnd/autogpt_server/autogpt_server/blocks/search.py
index afe541985e..31c264ee63 100644
--- a/rnd/autogpt_server/autogpt_server/blocks/search.py
+++ b/rnd/autogpt_server/autogpt_server/blocks/search.py
@@ -6,6 +6,7 @@ import requests
from autogpt_server.data.block import Block, BlockOutput, BlockSchema
from autogpt_server.data.model import BlockSecret, SecretField
+
class GetRequest:
@classmethod
def get_request(cls, url: str, json=False) -> Any:
@@ -141,16 +142,22 @@ class GetOpenWeatherMapWeather(Block, GetRequest):
id="f7a8b2c3-6d4e-5f8b-9e7f-6d4e5f8b9e7f",
input_schema=GetOpenWeatherMapWeather.Input,
output_schema=GetOpenWeatherMapWeather.Output,
- test_input={"location": "New York", "api_key": "YOUR_API_KEY", "use_celsius": True},
+ test_input={
+ "location": "New York",
+ "api_key": "YOUR_API_KEY",
+ "use_celsius": True,
+ },
test_output=[
("temperature", "21.66"),
("humidity", "32"),
- ("condition", "overcast clouds")
+ ("condition", "overcast clouds"),
],
- test_mock={"get_request": lambda url, json: {
- "main": {"temp": 21.66, "humidity": 32},
- "weather": [{"description": "overcast clouds"}]
- }},
+ test_mock={
+ "get_request": lambda url, json: {
+ "main": {"temp": 21.66, "humidity": 32},
+ "weather": [{"description": "overcast clouds"}],
+ }
+ },
)
def run(self, input_data: Input) -> BlockOutput:
@@ -161,19 +168,19 @@ class GetOpenWeatherMapWeather(Block, GetRequest):
url = f"http://api.openweathermap.org/data/2.5/weather?q={quote(location)}&appid={api_key}&units={units}"
weather_data = self.get_request(url, json=True)
- if 'main' in weather_data and 'weather' in weather_data:
- yield "temperature", str(weather_data['main']['temp'])
- yield "humidity", str(weather_data['main']['humidity'])
- yield "condition", weather_data['weather'][0]['description']
+ if "main" in weather_data and "weather" in weather_data:
+ yield "temperature", str(weather_data["main"]["temp"])
+ yield "humidity", str(weather_data["main"]["humidity"])
+ yield "condition", weather_data["weather"][0]["description"]
else:
yield "error", f"Expected keys not found in response: {weather_data}"
except requests.exceptions.HTTPError as http_err:
if http_err.response.status_code == 403:
- yield "error", f"Request to weather API failed: 403 Forbidden. Check your API key and permissions."
+ yield "error", "Request to weather API failed: 403 Forbidden. Check your API key and permissions."
else:
yield "error", f"HTTP error occurred: {http_err}"
except requests.RequestException as e:
yield "error", f"Request to weather API failed: {e}"
except KeyError as e:
- yield "error", f"Error processing weather data: {e}"
\ No newline at end of file
+ yield "error", f"Error processing weather data: {e}"
diff --git a/rnd/autogpt_server/autogpt_server/data/model.py b/rnd/autogpt_server/autogpt_server/data/model.py
index 56281bb28f..b86c05f25f 100644
--- a/rnd/autogpt_server/autogpt_server/data/model.py
+++ b/rnd/autogpt_server/autogpt_server/data/model.py
@@ -103,7 +103,7 @@ def SchemaField(
json_extra: dict[str, Any] = {}
if placeholder:
json_extra["placeholder"] = placeholder
- if secret:
+ if secret:
json_extra["secret"] = True
return Field(
diff --git a/rnd/autogpt_server/autogpt_server/util/settings.py b/rnd/autogpt_server/autogpt_server/util/settings.py
index 2f1f3f9e2c..b320051f9a 100644
--- a/rnd/autogpt_server/autogpt_server/util/settings.py
+++ b/rnd/autogpt_server/autogpt_server/util/settings.py
@@ -80,7 +80,9 @@ class Secrets(UpdateTrackingModel["Secrets"], BaseSettings):
reddit_username: str = Field(default="", description="Reddit username")
reddit_password: str = Field(default="", description="Reddit password")
- openweathermap_api_key: str = Field(default="", description="OpenWeatherMap API key")
+ openweathermap_api_key: str = Field(
+ default="", description="OpenWeatherMap API key"
+ )
medium_api_key: str = Field(default="", description="Medium API key")
medium_author_id: str = Field(default="", description="Medium author ID")