Skip to content

Commit 98d5fdd

Browse files
committed
fix: add noqa comments for Python 3.10 compatibility
- Add noqa: UP017 comments to suppress ruff warnings for timezone.utc usage - Maintain Python 3.10 compatibility while satisfying code quality checks - Resolve all ruff linting issues for clean CI/CD pipeline
1 parent 8f12aae commit 98d5fdd

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

src/mockloop_mcp/mcp_audit_logger.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def log_tool_execution(
312312
Unique entry ID for the logged event
313313
"""
314314
entry_id = str(uuid.uuid4())
315-
timestamp = datetime.now(timezone.utc).isoformat()
315+
timestamp = datetime.now(timezone.utc).isoformat() # noqa: UP017
316316

317317
# Generate content hash if enabled
318318
content_hash = None
@@ -433,7 +433,7 @@ def log_resource_access(
433433
Unique entry ID for the logged event
434434
"""
435435
entry_id = str(uuid.uuid4())
436-
timestamp = datetime.now(timezone.utc).isoformat()
436+
timestamp = datetime.now(timezone.utc).isoformat() # noqa: UP017
437437

438438
# Generate content hash if enabled
439439
content_hash = None
@@ -542,7 +542,7 @@ def log_context_operation(
542542
Unique entry ID for the logged event
543543
"""
544544
entry_id = str(uuid.uuid4())
545-
timestamp = datetime.now(timezone.utc).isoformat()
545+
timestamp = datetime.now(timezone.utc).isoformat() # noqa: UP017
546546

547547
try:
548548
with sqlite3.connect(self.db_path) as conn:
@@ -624,7 +624,7 @@ def log_prompt_invocation(
624624
Unique entry ID for the logged event
625625
"""
626626
entry_id = str(uuid.uuid4())
627-
timestamp = datetime.now(timezone.utc).isoformat()
627+
timestamp = datetime.now(timezone.utc).isoformat() # noqa: UP017
628628

629629
# Use generated_output if provided, otherwise use execution_result
630630
output_data = (
@@ -781,7 +781,7 @@ def cleanup_expired_logs(self) -> int:
781781
Number of deleted log entries
782782
"""
783783
try:
784-
current_time = datetime.now(timezone.utc).isoformat()
784+
current_time = datetime.now(timezone.utc).isoformat() # noqa: UP017
785785

786786
with sqlite3.connect(self.db_path) as conn:
787787
cursor = conn.cursor()

src/mockloop_mcp/mcp_compliance.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def generate_compliance_report(
179179
report_id=self._generate_report_id(),
180180
report_type=f"{regulation.value}_compliance",
181181
regulation=regulation.value,
182-
generated_at=datetime.now(timezone.utc).isoformat(),
182+
generated_at=datetime.now(timezone.utc).isoformat(), # noqa: UP017
183183
period_start=start_date,
184184
period_end=end_date,
185185
total_operations=len(audit_logs),
@@ -357,7 +357,7 @@ def generate_data_lineage_report(
357357
"source_statistics": source_stats,
358358
"total_entries": len(lineage_map),
359359
"unique_sources": len(source_stats),
360-
"generated_at": datetime.now(timezone.utc).isoformat(),
360+
"generated_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
361361
}
362362

363363
def check_retention_compliance(self) -> dict[str, Any]:
@@ -367,7 +367,7 @@ def check_retention_compliance(self) -> dict[str, Any]:
367367
Returns:
368368
Retention compliance report
369369
"""
370-
current_time = datetime.now(timezone.utc)
370+
current_time = datetime.now(timezone.utc) # noqa: UP017
371371

372372
with sqlite3.connect(str(self.audit_db_path)) as conn:
373373
conn.row_factory = sqlite3.Row
@@ -434,7 +434,7 @@ def purge_expired_data(self, dry_run: bool = True) -> dict[str, Any]:
434434
Returns:
435435
Purge operation results
436436
"""
437-
current_time = datetime.now(timezone.utc)
437+
current_time = datetime.now(timezone.utc) # noqa: UP017
438438

439439
with sqlite3.connect(str(self.audit_db_path)) as conn:
440440
conn.row_factory = sqlite3.Row
@@ -529,7 +529,7 @@ def generate_privacy_impact_assessment(
529529
"risk_analysis": risk_analysis,
530530
"recommendations": recommendations,
531531
"compliance_status": risk_analysis.get("overall_risk_level", "unknown"),
532-
"generated_at": datetime.now(timezone.utc).isoformat(),
532+
"generated_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
533533
}
534534

535535
def _query_audit_logs(
@@ -634,7 +634,7 @@ def _analyze_compliance(
634634
"metadata": {
635635
"regulation": regulation.value,
636636
"total_logs_analyzed": len(audit_logs),
637-
"analysis_timestamp": datetime.now(timezone.utc).isoformat(),
637+
"analysis_timestamp": datetime.now(timezone.utc).isoformat(), # noqa: UP017
638638
},
639639
}
640640

src/mockloop_mcp/mcp_tools.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ async def run_test_iteration(
874874
# Record start time
875875
start_time = time.time()
876876
iteration_result["start_time"] = datetime.fromtimestamp(
877-
start_time, tz=timezone.utc
877+
start_time, tz=timezone.utc # noqa: UP017
878878
).isoformat()
879879

880880
# Get initial metrics if monitoring is enabled
@@ -891,7 +891,7 @@ async def run_test_iteration(
891891
# Record end time
892892
end_time = time.time()
893893
iteration_result["end_time"] = datetime.fromtimestamp(
894-
end_time, tz=timezone.utc
894+
end_time, tz=timezone.utc # noqa: UP017
895895
).isoformat()
896896

897897
# Collect final metrics
@@ -1114,7 +1114,7 @@ async def create_mcp_plugin(
11141114
"mode": mode,
11151115
"spec_source": spec_url_or_path,
11161116
"target_url": target_url,
1117-
"created_at": datetime.now(timezone.utc).isoformat(),
1117+
"created_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
11181118
"plugin_config": {},
11191119
"mcp_config": {},
11201120
"mock_server_path": None,
@@ -1278,7 +1278,7 @@ async def create_mcp_plugin(
12781278
"mode": mode,
12791279
"spec_source": spec_url_or_path,
12801280
"error": f"Plugin creation failed: {e!s}",
1281-
"created_at": datetime.now(timezone.utc).isoformat(),
1281+
"created_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
12821282
"plugin_config": {},
12831283
"mcp_config": {},
12841284
"mock_server_path": None,
@@ -1782,7 +1782,7 @@ def _generate_session_summary(session_data: dict[str, Any]) -> dict[str, Any]:
17821782
def _calculate_next_execution(schedule_config: dict[str, Any]) -> str:
17831783
"""Calculate next execution time."""
17841784
# Simplified implementation
1785-
return datetime.now(timezone.utc).isoformat()
1785+
return datetime.now(timezone.utc).isoformat() # noqa: UP017
17861786

17871787

17881788
def _validate_test_suite(test_suite: dict[str, Any]) -> dict[str, bool]:
@@ -2250,7 +2250,7 @@ async def generate_test_report(
22502250
"report_id": str(uuid.uuid4()),
22512251
"report_format": report_format,
22522252
"output_format": output_format,
2253-
"generated_at": datetime.now(timezone.utc).isoformat(),
2253+
"generated_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
22542254
"report_content": {},
22552255
"chart_data": None,
22562256
"export_data": None,
@@ -2303,7 +2303,7 @@ async def generate_test_report(
23032303
"report_format": report_format,
23042304
"output_format": output_format,
23052305
"error": f"Report generation failed: {e!s}",
2306-
"generated_at": datetime.now(timezone.utc).isoformat(),
2306+
"generated_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
23072307
"report_content": {},
23082308
"chart_data": None,
23092309
"export_data": None,
@@ -2547,7 +2547,7 @@ async def create_test_session(
25472547
"status": "success",
25482548
"session_id": session_id,
25492549
"session_name": session_name,
2550-
"created_at": datetime.now(timezone.utc).isoformat(),
2550+
"created_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
25512551
"test_plan": test_plan,
25522552
"session_config": session_config or {},
25532553
"session_state": "created",
@@ -2571,7 +2571,7 @@ async def create_test_session(
25712571
"session_id": None,
25722572
"session_name": session_name,
25732573
"error": f"Test session creation failed: {e!s}",
2574-
"created_at": datetime.now(timezone.utc).isoformat(),
2574+
"created_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
25752575
"test_plan": {},
25762576
"session_config": {},
25772577
"session_state": "error",
@@ -2599,14 +2599,14 @@ async def end_test_session(
25992599
"status": "error",
26002600
"session_id": session_id,
26012601
"error": "Test session not found",
2602-
"ended_at": datetime.now(timezone.utc).isoformat(),
2602+
"ended_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
26032603
"final_report": None,
26042604
"session_summary": {},
26052605
}
26062606

26072607
session_data = _active_test_sessions[session_id]
26082608
session_data["session_state"] = "completed"
2609-
session_data["ended_at"] = datetime.now(timezone.utc).isoformat()
2609+
session_data["ended_at"] = datetime.now(timezone.utc).isoformat() # noqa: UP017
26102610

26112611
end_result = {
26122612
"status": "success",
@@ -2640,7 +2640,7 @@ async def end_test_session(
26402640
"status": "error",
26412641
"session_id": session_id,
26422642
"error": f"Test session completion failed: {e!s}",
2643-
"ended_at": datetime.now(timezone.utc).isoformat(),
2643+
"ended_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
26442644
"final_report": None,
26452645
"session_summary": {},
26462646
}
@@ -2671,7 +2671,7 @@ async def schedule_test_suite(
26712671
"test_suite": test_suite,
26722672
"schedule_config": schedule_config,
26732673
"notification_config": notification_config or {},
2674-
"created_at": datetime.now(timezone.utc).isoformat(),
2674+
"created_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
26752675
"next_execution": _calculate_next_execution(schedule_config),
26762676
"schedule_state": "active",
26772677
"validation_result": _validate_test_suite(test_suite),
@@ -2695,7 +2695,7 @@ async def schedule_test_suite(
26952695
"test_suite": {},
26962696
"schedule_config": {},
26972697
"notification_config": {},
2698-
"created_at": datetime.now(timezone.utc).isoformat(),
2698+
"created_at": datetime.now(timezone.utc).isoformat(), # noqa: UP017
26992699
"next_execution": None,
27002700
"schedule_state": "error",
27012701
"validation_result": {"valid": False, "errors": []},
@@ -2726,7 +2726,7 @@ async def monitor_test_progress(
27262726
"progress": {},
27272727
"performance_data": {},
27282728
"alerts": [],
2729-
"monitoring_timestamp": datetime.now(timezone.utc).isoformat(),
2729+
"monitoring_timestamp": datetime.now(timezone.utc).isoformat(), # noqa: UP017
27302730
}
27312731

27322732
session_data = _active_test_sessions[session_id]
@@ -2740,7 +2740,7 @@ async def monitor_test_progress(
27402740
"progress_percentage": _calculate_progress_percentage(progress),
27412741
"performance_data": {},
27422742
"alerts": [],
2743-
"monitoring_timestamp": datetime.now(timezone.utc).isoformat(),
2743+
"monitoring_timestamp": datetime.now(timezone.utc).isoformat(), # noqa: UP017
27442744
}
27452745

27462746
# Include performance data if requested
@@ -2777,7 +2777,7 @@ async def monitor_test_progress(
27772777
"progress": {},
27782778
"performance_data": {},
27792779
"alerts": [],
2780-
"monitoring_timestamp": datetime.now(timezone.utc).isoformat(),
2780+
"monitoring_timestamp": datetime.now(timezone.utc).isoformat(), # noqa: UP017
27812781
}
27822782

27832783

@@ -3103,7 +3103,7 @@ async def _register_mcp_plugin(plugin_config: PluginConfig) -> dict[str, Any]:
31033103
"status": "success",
31043104
"registered": True,
31053105
"plugin_id": plugin_config.mcp_server_name,
3106-
"registration_time": datetime.now(timezone.utc).isoformat(),
3106+
"registration_time": datetime.now(timezone.utc).isoformat(), # noqa: UP017
31073107
"message": f"Plugin {plugin_config.plugin_name} registered successfully",
31083108
}
31093109

@@ -3115,7 +3115,7 @@ async def _register_mcp_plugin(plugin_config: PluginConfig) -> dict[str, Any]:
31153115
"status": "error",
31163116
"registered": False,
31173117
"error": str(e),
3118-
"registration_time": datetime.now(timezone.utc).isoformat(),
3118+
"registration_time": datetime.now(timezone.utc).isoformat(), # noqa: UP017
31193119
}
31203120

31213121

0 commit comments

Comments
 (0)