Skip to content

Commit ad8df5d

Browse files
committed
style: lint and format
1 parent aa2febd commit ad8df5d

21 files changed

+152
-122
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ run:
88
run-sse:
99
$(PYTHON) src --transport sse $(PARAMS)
1010
build:
11-
$(PYTHON) -m build
11+
uv build
1212
publish:
13-
$(PYTHON) -m twine upload --config-file .pypirc dist/*
13+
uv publish
1414
lint:
1515
$(PYTHON) -m ruff check . --fix
1616
format:

pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,8 @@ include = [
5757
[tool.ruff]
5858
select = ["E", "W", "F", "B", "I"]
5959
line-length = 120
60+
61+
[dependency-groups]
62+
dev = [
63+
"ruff>=0.11.0",
64+
]

src/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
# To load all tools
2-
from src.airflow import *

src/airflow/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
1+
from typing import Any, Callable, Dict, List, Optional, Union
22

33
import mcp.types as types
44
from airflow_client.client.api.config_api import ConfigApi
@@ -22,7 +22,7 @@ async def get_config(
2222
kwargs: Dict[str, Any] = {}
2323
if section is not None:
2424
kwargs["section"] = section
25-
25+
2626
response = config_api.get_config(**kwargs)
2727
return [types.TextContent(type="text", text=str(response.to_dict()))]
2828

src/airflow/connection.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
1+
from typing import Any, Callable, Dict, List, Optional, Union
22

33
import mcp.types as types
4-
54
from airflow_client.client.api.connection_api import ConnectionApi
65

76
from src.airflow.airflow_client import api_client
@@ -33,7 +32,7 @@ async def list_connections(
3332
kwargs["offset"] = offset
3433
if order_by is not None:
3534
kwargs["order_by"] = order_by
36-
35+
3736
response = connection_api.get_connections(**kwargs)
3837
return [types.TextContent(type="text", text=str(response.to_dict()))]
3938

@@ -64,14 +63,12 @@ async def create_connection(
6463
connection_request["schema"] = schema
6564
if extra is not None:
6665
connection_request["extra"] = extra
67-
66+
6867
response = connection_api.post_connection(connection_request=connection_request)
6968
return [types.TextContent(type="text", text=str(response.to_dict()))]
7069

7170

72-
async def get_connection(
73-
conn_id: str
74-
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
71+
async def get_connection(conn_id: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
7572
response = connection_api.get_connection(connection_id=conn_id)
7673
return [types.TextContent(type="text", text=str(response.to_dict()))]
7774

@@ -101,18 +98,14 @@ async def update_connection(
10198
update_request["schema"] = schema
10299
if extra is not None:
103100
update_request["extra"] = extra
104-
101+
105102
response = connection_api.patch_connection(
106-
connection_id=conn_id,
107-
update_mask=list(update_request.keys()),
108-
connection_request=update_request
103+
connection_id=conn_id, update_mask=list(update_request.keys()), connection_request=update_request
109104
)
110105
return [types.TextContent(type="text", text=str(response.to_dict()))]
111106

112107

113-
async def delete_connection(
114-
conn_id: str
115-
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
108+
async def delete_connection(conn_id: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
116109
response = connection_api.delete_connection(connection_id=conn_id)
117110
return [types.TextContent(type="text", text=str(response.to_dict()))]
118111

@@ -141,6 +134,6 @@ async def test_connection(
141134
connection_request["schema"] = schema
142135
if extra is not None:
143136
connection_request["extra"] = extra
144-
137+
145138
response = connection_api.test_connection(connection_request=connection_request)
146139
return [types.TextContent(type="text", text=str(response.to_dict()))]

src/airflow/dag.py

+22-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
1+
from typing import Any, Callable, Dict, List, Optional, Union
22

33
import mcp.types as types
44
from airflow_client.client.api.dag_api import DAGApi
55
from airflow_client.client.model.clear_task_instances import ClearTaskInstances
6-
from airflow_client.client.model.update_task_instances_state import UpdateTaskInstancesState
76
from airflow_client.client.model.dag import DAG
7+
from airflow_client.client.model.update_task_instances_state import UpdateTaskInstancesState
8+
89
from src.airflow.airflow_client import api_client
910
from src.envs import AIRFLOW_HOST
1011

@@ -86,12 +87,14 @@ async def get_dag(dag_id: str) -> List[Union[types.TextContent, types.ImageConte
8687
return [types.TextContent(type="text", text=str(response_dict))]
8788

8889

89-
async def get_dag_details(dag_id: str, fields: Optional[List[str]] = None) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
90+
async def get_dag_details(
91+
dag_id: str, fields: Optional[List[str]] = None
92+
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
9093
# Build parameters dictionary
9194
kwargs: Dict[str, Any] = {}
9295
if fields is not None:
9396
kwargs["fields"] = fields
94-
97+
9598
response = dag_api.get_dag_details(dag_id=dag_id, **kwargs)
9699
return [types.TextContent(type="text", text=str(response.to_dict()))]
97100

@@ -136,11 +139,13 @@ async def patch_dag(
136139

137140

138141
async def patch_dags(
139-
dag_id_pattern: Optional[str] = None, is_paused: Optional[bool] = None, tags: Optional[List[str]] = None,
142+
dag_id_pattern: Optional[str] = None,
143+
is_paused: Optional[bool] = None,
144+
tags: Optional[List[str]] = None,
140145
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
141146
update_request = {}
142147
update_mask = []
143-
148+
144149
if is_paused is not None:
145150
update_request["is_paused"] = is_paused
146151
update_mask.append("is_paused")
@@ -153,7 +158,7 @@ async def patch_dags(
153158
kwargs = {}
154159
if dag_id_pattern is not None:
155160
kwargs["dag_id_pattern"] = dag_id_pattern
156-
161+
157162
response = dag_api.patch_dags(dag_id_pattern=dag_id_pattern, dag=dag, update_mask=update_mask, **kwargs)
158163
return [types.TextContent(type="text", text=str(response.to_dict()))]
159164

@@ -170,7 +175,9 @@ async def get_task(
170175
return [types.TextContent(type="text", text=str(response.to_dict()))]
171176

172177

173-
async def get_tasks(dag_id: str, order_by: Optional[str] = None) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
178+
async def get_tasks(
179+
dag_id: str, order_by: Optional[str] = None
180+
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
174181
kwargs = {}
175182
if order_by is not None:
176183
kwargs["order_by"] = order_by
@@ -218,7 +225,7 @@ async def clear_task_instances(
218225
clear_request["reset_dag_runs"] = reset_dag_runs
219226

220227
clear_task_instances = ClearTaskInstances(**clear_request)
221-
228+
222229
response = dag_api.post_clear_task_instances(dag_id=dag_id, clear_task_instances=clear_task_instances)
223230
return [types.TextContent(type="text", text=str(response.to_dict()))]
224231

@@ -234,9 +241,7 @@ async def set_task_instances_state(
234241
include_past: Optional[bool] = None,
235242
dry_run: Optional[bool] = None,
236243
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
237-
state_request = {
238-
"state": state
239-
}
244+
state_request = {"state": state}
240245
if task_ids is not None:
241246
state_request["task_ids"] = task_ids
242247
if execution_date is not None:
@@ -254,12 +259,15 @@ async def set_task_instances_state(
254259

255260
update_task_instances_state = UpdateTaskInstancesState(**state_request)
256261

257-
response = dag_api.post_set_task_instances_state(dag_id=dag_id, update_task_instances_state=update_task_instances_state)
262+
response = dag_api.post_set_task_instances_state(
263+
dag_id=dag_id,
264+
update_task_instances_state=update_task_instances_state,
265+
)
258266
return [types.TextContent(type="text", text=str(response.to_dict()))]
259267

260268

261269
async def reparse_dag_file(
262-
file_token: str
270+
file_token: str,
263271
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
264272
response = dag_api.reparse_dag_file(file_token=file_token)
265273
return [types.TextContent(type="text", text=str(response.to_dict()))]

src/airflow/dagrun.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
21
from datetime import datetime
2+
from typing import Any, Callable, Dict, List, Optional, Union
33

44
import mcp.types as types
55
from airflow_client.client.api.dag_run_api import DAGRunApi
@@ -27,6 +27,7 @@ def get_all_functions() -> list[tuple[Callable, str, str]]:
2727
(get_upstream_dataset_events, "get_upstream_dataset_events", "Get dataset events for a DAG run"),
2828
]
2929

30+
3031
def get_dag_run_url(dag_id: str, dag_run_id: str) -> str:
3132
return f"{AIRFLOW_HOST}/dags/{dag_id}/grid?dag_run_id={dag_run_id}"
3233

@@ -158,36 +159,40 @@ async def get_dag_runs_batch(
158159
request["page_limit"] = page_limit
159160

160161
response = dag_run_api.get_dag_runs_batch(list_dag_runs_form=request)
161-
162+
162163
# Convert response to dictionary for easier manipulation
163164
response_dict = response.to_dict()
164-
165+
165166
# Add UI links to each DAG run
166167
for dag_run in response_dict.get("dag_runs", []):
167168
dag_run["ui_url"] = get_dag_run_url(dag_run["dag_id"], dag_run["dag_run_id"])
168-
169+
169170
return [types.TextContent(type="text", text=str(response_dict))]
170171

171172

172173
async def get_dag_run(
173174
dag_id: str, dag_run_id: str
174175
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
175176
response = dag_run_api.get_dag_run(dag_id=dag_id, dag_run_id=dag_run_id)
176-
177+
177178
# Convert response to dictionary for easier manipulation
178179
response_dict = response.to_dict()
179-
180+
180181
# Add UI link to DAG run
181182
response_dict["ui_url"] = get_dag_run_url(dag_id, dag_run_id)
182-
183+
183184
return [types.TextContent(type="text", text=str(response_dict))]
184185

185186

186187
async def update_dag_run_state(
187188
dag_id: str, dag_run_id: str, state: Optional[str] = None
188189
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
189190
update_dag_run_state = UpdateDagRunState(state=state)
190-
response = dag_run_api.update_dag_run_state(dag_id=dag_id, dag_run_id=dag_run_id, update_dag_run_state=update_dag_run_state)
191+
response = dag_run_api.update_dag_run_state(
192+
dag_id=dag_id,
193+
dag_run_id=dag_run_id,
194+
update_dag_run_state=update_dag_run_state,
195+
)
191196
return [types.TextContent(type="text", text=str(response.to_dict()))]
192197

193198

src/airflow/dagstats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
1+
from typing import Any, Callable, Dict, List, Optional, Union
22

33
import mcp.types as types
44
from airflow_client.client.api.dag_stats_api import DagStatsApi
@@ -21,6 +21,6 @@ async def get_dag_stats(
2121
kwargs: Dict[str, Any] = {}
2222
if dag_ids is not None:
2323
kwargs["dag_ids"] = dag_ids
24-
24+
2525
response = dag_stats_api.get_dag_stats(**kwargs)
2626
return [types.TextContent(type="text", text=str(response.to_dict()))]

src/airflow/dataset.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
1+
from typing import Any, Callable, Dict, List, Optional, Union
22

33
import mcp.types as types
44
from airflow_client.client.api.dataset_api import DatasetApi
@@ -17,7 +17,11 @@ def get_all_functions() -> list[tuple[Callable, str, str]]:
1717
(get_dag_dataset_queued_event, "get_dag_dataset_queued_event", "Get a queued Dataset event for a DAG"),
1818
(get_dag_dataset_queued_events, "get_dag_dataset_queued_events", "Get queued Dataset events for a DAG"),
1919
(delete_dag_dataset_queued_event, "delete_dag_dataset_queued_event", "Delete a queued Dataset event for a DAG"),
20-
(delete_dag_dataset_queued_events, "delete_dag_dataset_queued_events", "Delete queued Dataset events for a DAG"),
20+
(
21+
delete_dag_dataset_queued_events,
22+
"delete_dag_dataset_queued_events",
23+
"Delete queued Dataset events for a DAG",
24+
),
2125
(get_dataset_queued_events, "get_dataset_queued_events", "Get queued Dataset events for a Dataset"),
2226
(delete_dataset_queued_events, "delete_dataset_queued_events", "Delete queued Dataset events for a Dataset"),
2327
]
@@ -42,7 +46,7 @@ async def get_datasets(
4246
kwargs["uri_pattern"] = uri_pattern
4347
if dag_ids is not None:
4448
kwargs["dag_ids"] = dag_ids
45-
49+
4650
response = dataset_api.get_datasets(**kwargs)
4751
return [types.TextContent(type="text", text=str(response.to_dict()))]
4852

@@ -82,7 +86,7 @@ async def get_dataset_events(
8286
kwargs["source_run_id"] = source_run_id
8387
if source_map_index is not None:
8488
kwargs["source_map_index"] = source_map_index
85-
89+
8690
response = dataset_api.get_dataset_events(**kwargs)
8791
return [types.TextContent(type="text", text=str(response.to_dict()))]
8892

@@ -96,7 +100,7 @@ async def create_dataset_event(
96100
}
97101
if extra is not None:
98102
event_request["extra"] = extra
99-
103+
100104
response = dataset_api.create_dataset_event(create_dataset_event=event_request)
101105
return [types.TextContent(type="text", text=str(response.to_dict()))]
102106

@@ -131,7 +135,7 @@ async def delete_dag_dataset_queued_events(
131135
kwargs: Dict[str, Any] = {}
132136
if before is not None:
133137
kwargs["before"] = before
134-
138+
135139
response = dataset_api.delete_dag_dataset_queued_events(dag_id=dag_id, **kwargs)
136140
return [types.TextContent(type="text", text=str(response.to_dict()))]
137141

@@ -150,7 +154,6 @@ async def delete_dataset_queued_events(
150154
kwargs: Dict[str, Any] = {}
151155
if before is not None:
152156
kwargs["before"] = before
153-
157+
154158
response = dataset_api.delete_dataset_queued_events(uri=uri, **kwargs)
155159
return [types.TextContent(type="text", text=str(response.to_dict()))]
156-

src/airflow/eventlog.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
21
from datetime import datetime
2+
from typing import Any, Callable, Dict, List, Optional, Union
33

44
import mcp.types as types
55
from airflow_client.client.api.event_log_api import EventLogApi
@@ -62,7 +62,7 @@ async def get_event_logs(
6262
kwargs["included_events"] = included_events
6363
if excluded_events is not None:
6464
kwargs["excluded_events"] = excluded_events
65-
65+
6666
response = event_log_api.get_event_logs(**kwargs)
6767
return [types.TextContent(type="text", text=str(response.to_dict()))]
6868

@@ -72,4 +72,3 @@ async def get_event_log(
7272
) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
7373
response = event_log_api.get_event_log(event_log_id=event_log_id)
7474
return [types.TextContent(type="text", text=str(response.to_dict()))]
75-

src/airflow/importerror.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from typing import Any, Dict, List, Optional, Union, Callable
1+
from typing import Any, Callable, Dict, List, Optional, Union
22

33
import mcp.types as types
44
from airflow_client.client.api.import_error_api import ImportErrorApi
55

66
from src.airflow.airflow_client import api_client
77

8-
98
import_error_api = ImportErrorApi(api_client)
109

1110

@@ -29,7 +28,7 @@ async def get_import_errors(
2928
kwargs["offset"] = offset
3029
if order_by is not None:
3130
kwargs["order_by"] = order_by
32-
31+
3332
response = import_error_api.get_import_errors(**kwargs)
3433
return [types.TextContent(type="text", text=str(response.to_dict()))]
3534

src/airflow/monitoring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Union, Callable
1+
from typing import Callable, List, Union
22

33
import mcp.types as types
44
from airflow_client.client.api.monitoring_api import MonitoringApi

0 commit comments

Comments
 (0)