Skip to content

Commit 5fa47b5

Browse files
committed
autoflake8 isort pylint fixes
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 4c91d83 commit 5fa47b5

File tree

6 files changed

+65
-65
lines changed

6 files changed

+65
-65
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,4 @@ DEBUG=false
289289

290290
# Gateway tool name separator
291291
GATEWAY_TOOL_NAME_SEPARATOR=-
292-
VALID_SLUG_SEPARATOR_REGEXP= r"^(-{1,2}|[_.])$"
292+
VALID_SLUG_SEPARATOR_REGEXP= r"^(-{1,2}|[_.])$"

.github/workflows/check-headers.yml.inactive

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ on:
3636
- '**.py'
3737
- '.github/workflows/check-headers.yml'
3838
- '.github/tools/fix_file_headers.py'
39-
39+
4040
push:
41-
branches:
41+
branches:
4242
- main
4343
- master
4444
paths:
4545
- '**.py'
46-
46+
4747
workflow_dispatch:
4848
inputs:
4949
debug_mode:
@@ -75,7 +75,7 @@ jobs:
7575
check-headers:
7676
name: 🔍 Validate Python Headers
7777
runs-on: ubuntu-latest
78-
78+
7979
steps:
8080
# -----------------------------------------------------------
8181
# 0️⃣ Checkout repository
@@ -115,32 +115,32 @@ jobs:
115115
id: check
116116
run: |
117117
echo "🔍 Checking Python file headers..."
118-
118+
119119
# Build command based on inputs
120120
CHECK_CMD="python3 .github/tools/fix_file_headers.py"
121-
121+
122122
# Add flags based on workflow inputs
123123
if [[ "${{ inputs.show_diff }}" == "true" ]] || [[ "${{ github.event_name }}" == "pull_request" ]]; then
124124
CHECK_CMD="$CHECK_CMD --show-diff"
125125
fi
126-
126+
127127
if [[ "${{ inputs.debug_mode }}" == "true" ]]; then
128128
CHECK_CMD="$CHECK_CMD --debug"
129129
fi
130-
130+
131131
echo "🏃 Running: $CHECK_CMD"
132-
132+
133133
# Run check and capture output
134134
if $CHECK_CMD > header-check-output.txt 2>&1; then
135135
echo "✅ All Python file headers are correct!"
136136
echo "check_passed=true" >> $GITHUB_OUTPUT
137137
else
138138
echo "❌ Some files have incorrect headers"
139139
echo "check_passed=false" >> $GITHUB_OUTPUT
140-
140+
141141
# Show the output
142142
cat header-check-output.txt
143-
143+
144144
# Save summary for PR comment
145145
echo '```' > header-check-summary.md
146146
cat header-check-output.txt >> header-check-summary.md
@@ -157,35 +157,35 @@ jobs:
157157
script: |
158158
const fs = require('fs');
159159
const summary = fs.readFileSync('header-check-summary.md', 'utf8');
160-
160+
161161
const body = `## ❌ Python Header Check Failed
162-
162+
163163
Some Python files have incorrect or missing headers. Please fix them before merging.
164-
164+
165165
### 🔧 How to fix:
166-
166+
167167
1. **Fix all files automatically:**
168168
\`\`\`bash
169169
make fix-all-headers
170170
\`\`\`
171-
171+
172172
2. **Fix specific files:**
173173
\`\`\`bash
174174
make fix-header path=path/to/file.py
175175
\`\`\`
176-
176+
177177
3. **Review changes interactively:**
178178
\`\`\`bash
179179
make interactive-fix-headers
180180
\`\`\`
181-
181+
182182
### 📋 Check Results:
183-
183+
184184
${summary}
185-
185+
186186
---
187187
🤖 *This check ensures all Python files have proper copyright, license, and author information.*`;
188-
188+
189189
github.rest.issues.createComment({
190190
issue_number: context.issue.number,
191191
owner: context.repo.owner,
@@ -223,4 +223,4 @@ jobs:
223223
if: steps.check.outputs.check_passed == 'true'
224224
run: |
225225
echo "✅ All Python file headers are properly formatted!"
226-
echo "🎉 No action needed."
226+
echo "🎉 No action needed."

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2131,4 +2131,4 @@ Special thanks to our contributors for helping us improve ContextForge MCP Gatew
21312131
[![Forks](https://img.shields.io/github/forks/ibm/mcp-context-forge?style=social)](https://github.com/ibm/mcp-context-forge/network/members)&nbsp;
21322132
[![Contributors](https://img.shields.io/github/contributors/ibm/mcp-context-forge)](https://github.com/ibm/mcp-context-forge/graphs/contributors)&nbsp;
21332133
[![Last Commit](https://img.shields.io/github/last-commit/ibm/mcp-context-forge)](https://github.com/ibm/mcp-context-forge/commits)&nbsp;
2134-
[![Open Issues](https://img.shields.io/github/issues/ibm/mcp-context-forge)](https://github.com/ibm/mcp-context-forge/issues)&nbsp;
2134+
[![Open Issues](https://img.shields.io/github/issues/ibm/mcp-context-forge)](https://github.com/ibm/mcp-context-forge/issues)&nbsp;

docs/docs/using/plugins/index.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The MCP Gateway Plugin Framework provides a standardized way to extend gateway f
99

1010
- **Content Filtering** - PII detection and masking
1111
- **AI Safety** - Integration with LLMGuard, OpenAI Moderation
12-
- **Security** - Input validation and output sanitization
12+
- **Security** - Input validation and output sanitization
1313
- **Policy Enforcement** - Business rules and compliance
1414
- **Transformation** - Request/response modification
1515
- **Auditing** - Logging and monitoring
@@ -97,13 +97,13 @@ Plugins execute in priority order (ascending):
9797
plugins:
9898
- name: "Authentication"
9999
priority: 10 # Runs first
100-
101-
- name: "RateLimiter"
100+
101+
- name: "RateLimiter"
102102
priority: 50 # Runs second
103-
103+
104104
- name: "ContentFilter"
105105
priority: 100 # Runs third
106-
106+
107107
- name: "Logger"
108108
priority: 200 # Runs last
109109
```
@@ -144,23 +144,23 @@ from mcpgateway.plugins.framework.types import (
144144
145145
class MyPlugin(Plugin):
146146
"""Example plugin implementation."""
147-
147+
148148
def __init__(self, config: PluginConfig):
149149
super().__init__(config)
150150
# Initialize plugin-specific configuration
151151
self.my_setting = config.config.get("my_setting", "default")
152-
152+
153153
async def prompt_pre_fetch(
154-
self,
155-
payload: PromptPrehookPayload,
154+
self,
155+
payload: PromptPrehookPayload,
156156
context: PluginContext
157157
) -> PromptPrehookResult:
158158
"""Process prompt before retrieval."""
159-
159+
160160
# Access prompt name and arguments
161161
prompt_name = payload.name
162162
args = payload.args
163-
163+
164164
# Example: Block requests with forbidden words
165165
if "forbidden" in str(args.values()).lower():
166166
return PromptPrehookResult(
@@ -172,40 +172,40 @@ class MyPlugin(Plugin):
172172
details={"found_in": "arguments"}
173173
)
174174
)
175-
175+
176176
# Example: Modify arguments
177177
if "transform_me" in args:
178178
args["transform_me"] = args["transform_me"].upper()
179179
return PromptPrehookResult(
180180
modified_payload=PromptPrehookPayload(prompt_name, args)
181181
)
182-
182+
183183
# Allow request to continue unchanged
184184
return PromptPrehookResult()
185-
185+
186186
async def prompt_post_fetch(
187187
self,
188188
payload: PromptPosthookPayload,
189189
context: PluginContext
190190
) -> PromptPosthookResult:
191191
"""Process prompt after rendering."""
192-
192+
193193
# Access rendered prompt
194194
prompt_result = payload.result
195-
195+
196196
# Example: Add metadata to context
197197
context.metadata["processed_by"] = self.name
198-
198+
199199
# Example: Modify response
200200
for message in prompt_result.messages:
201201
message.content.text = message.content.text.replace(
202202
"old_text", "new_text"
203203
)
204-
204+
205205
return PromptPosthookResult(
206206
modified_payload=payload
207207
)
208-
208+
209209
async def shutdown(self):
210210
"""Cleanup when plugin shuts down."""
211211
# Close connections, save state, etc.
@@ -221,17 +221,17 @@ async def prompt_pre_fetch(self, payload, context):
221221
# Store state for later use
222222
context.set_state("request_time", time.time())
223223
context.set_state("original_args", payload.args.copy())
224-
224+
225225
return PromptPrehookResult()
226226
227227
async def prompt_post_fetch(self, payload, context):
228228
# Retrieve state from pre-hook
229229
elapsed = time.time() - context.get_state("request_time", 0)
230230
original = context.get_state("original_args", {})
231-
231+
232232
# Add timing metadata
233233
context.metadata["processing_time_ms"] = elapsed * 1000
234-
234+
235235
return PromptPosthookResult()
236236
```
237237

@@ -240,13 +240,13 @@ async def prompt_post_fetch(self, payload, context):
240240
```python
241241
class LLMGuardPlugin(Plugin):
242242
"""Example external service integration."""
243-
243+
244244
def __init__(self, config: PluginConfig):
245245
super().__init__(config)
246246
self.service_url = config.config.get("service_url")
247247
self.api_key = config.config.get("api_key")
248248
self.timeout = config.config.get("timeout", 30)
249-
249+
250250
async def prompt_pre_fetch(self, payload, context):
251251
# Call external service
252252
async with httpx.AsyncClient() as client:
@@ -262,9 +262,9 @@ class LLMGuardPlugin(Plugin):
262262
},
263263
timeout=self.timeout
264264
)
265-
265+
266266
result = response.json()
267-
267+
268268
if result.get("blocked", False):
269269
return PromptPrehookResult(
270270
continue_processing=False,
@@ -275,7 +275,7 @@ class LLMGuardPlugin(Plugin):
275275
details=result
276276
)
277277
)
278-
278+
279279
except Exception as e:
280280
# Handle errors based on plugin settings
281281
if self.config.mode == PluginMode.ENFORCE:
@@ -288,7 +288,7 @@ class LLMGuardPlugin(Plugin):
288288
details={"error": str(e)}
289289
)
290290
)
291-
291+
292292
return PromptPrehookResult()
293293
```
294294

@@ -357,9 +357,9 @@ async def test_my_plugin():
357357
hooks=["prompt_pre_fetch"],
358358
config={"setting_one": "test_value"}
359359
)
360-
360+
361361
plugin = MyPlugin(config)
362-
362+
363363
# Test your plugin logic
364364
result = await plugin.prompt_pre_fetch(payload, context)
365365
assert result.continue_processing
@@ -378,11 +378,11 @@ async def prompt_pre_fetch(self, payload, context):
378378
pass
379379
except Exception as e:
380380
logger.error(f"Plugin {self.name} error: {e}")
381-
381+
382382
# In permissive mode, log and continue
383383
if self.mode == PluginMode.PERMISSIVE:
384384
return PromptPrehookResult()
385-
385+
386386
# In enforce mode, block the request
387387
return PromptPrehookResult(
388388
continue_processing=False,
@@ -408,17 +408,17 @@ class CachedPlugin(Plugin):
408408
super().__init__(config)
409409
self._cache = {}
410410
self._cache_ttl = config.config.get("cache_ttl", 300)
411-
411+
412412
async def expensive_operation(self, key):
413413
# Check cache first
414414
if key in self._cache:
415415
cached_value, timestamp = self._cache[key]
416416
if time.time() - timestamp < self._cache_ttl:
417417
return cached_value
418-
418+
419419
# Perform expensive operation
420420
result = await self._do_expensive_work(key)
421-
421+
422422
# Cache result
423423
self._cache[key] = (result, time.time())
424424
return result

tests/e2e/test_main_apis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ async def test_resource_uri_conflict(self, client: AsyncClient, mock_auth):
639639
assert "already exists" in resp_json["message"]
640640
else:
641641
# Accept any error format as long as status is correct
642-
assert response.status_code == 409
642+
assert response.status_code == 409
643643

644644
"""Test resource management endpoints."""
645645

0 commit comments

Comments
 (0)