Skip to content

Commit 21eddc0

Browse files
committed
Fix Python static analysis and code quality issues
✅ Resolve CI failures: - Fixed all mypy type annotation errors in src/parsers/ module - Added proper type hints for variables and functions - Resolved import sorting and formatting issues with ruff 🔧 Type annotation improvements: - Added type hints for dictionary/list variables in database utils - Fixed return type annotations in database models - Used cast() for runtime-validated values - Added proper type annotations for class properties 📝 Code formatting and style: - Fixed import ordering across all Python files - Removed unnecessary trailing whitespace in __init__.py files - Applied consistent string quoting and formatting - Fixed function signatures and argument formatting ✅ All tests passing (78/78) ✅ MyPy static analysis clean ✅ Core functionality verified The CI pipeline should now pass all Python static analysis and unit test checks.
1 parent d5207e0 commit 21eddc0

31 files changed

+884
-674
lines changed

doc/CodeDocs/conf.py

Lines changed: 396 additions & 328 deletions
Large diffs are not rendered by default.

examples/deepagent_demo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@
77
- Run the agent with a session ID to demonstrate conversational memory.
88
"""
99

10-
import sys
1110
from pathlib import Path
11+
import sys
1212

1313
# Add src to path for imports
1414
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
1515

1616
from agents.deepagent import FlexibleAgent
17+
1718
try:
1819
from dotenv import load_dotenv # type: ignore
1920
except Exception:
21+
2022
def load_dotenv(*_args, **_kwargs): # type: ignore
2123
return False
2224

25+
2326
def main():
2427
"""Main demonstration function."""
2528
print("🤖 FlexibleAgent Demo")
@@ -43,7 +46,6 @@ def main():
4346
print(f" ❌ Error: {e}")
4447
print(" Please ensure you have a valid API key in your .env file.")
4548

46-
4749
# --- Conversational Memory with Session ID ---
4850
print("\n--- Conversational Memory with Session ID ---")
4951
try:

examples/parser_demo.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
from diagram files and store them in the database.
77
"""
88

9-
import sys
109
from pathlib import Path
10+
import sys
1111

1212
# Add src to path for imports
1313
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
1414

15-
from parsers import PlantUMLParser, MermaidParser, DrawIOParser
16-
from parsers.database import DiagramDatabase, get_diagram_statistics
15+
from parsers import DrawIOParser
16+
from parsers import MermaidParser
17+
from parsers import PlantUMLParser
18+
from parsers.database import DiagramDatabase
19+
from parsers.database import get_diagram_statistics
1720

1821

1922
def create_sample_diagrams():
@@ -82,9 +85,9 @@ class Cat {
8285
</mxGraphModel>"""
8386

8487
return {
85-
'plantuml': plantuml_content,
86-
'mermaid': mermaid_content,
87-
'drawio': drawio_content
88+
"plantuml": plantuml_content,
89+
"mermaid": mermaid_content,
90+
"drawio": drawio_content,
8891
}
8992

9093

@@ -99,9 +102,9 @@ def main():
99102

100103
# Create parsers
101104
parsers = {
102-
'PlantUML': PlantUMLParser(),
103-
'Mermaid': MermaidParser(),
104-
'DrawIO': DrawIOParser()
105+
"PlantUML": PlantUMLParser(),
106+
"Mermaid": MermaidParser(),
107+
"DrawIO": DrawIOParser(),
105108
}
106109

107110
# Get sample diagrams
@@ -114,14 +117,14 @@ def main():
114117
print(f"\n📊 Testing {parser_name} Parser")
115118
print("-" * 30)
116119

117-
if parser_name == 'PlantUML':
118-
content = samples['plantuml']
120+
if parser_name == "PlantUML":
121+
content = samples["plantuml"]
119122
filename = "sample.puml"
120-
elif parser_name == 'Mermaid':
121-
content = samples['mermaid']
123+
elif parser_name == "Mermaid":
124+
content = samples["mermaid"]
122125
filename = "sample.mmd"
123126
else: # DrawIO
124-
content = samples['drawio']
127+
content = samples["drawio"]
125128
filename = "sample.drawio"
126129

127130
try:

scripts/evaluate-prompt.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import os
21
import argparse
2+
import os
3+
34
from src.agents import deepagent
5+
46
try:
57
from dotenv import load_dotenv # type: ignore
68
except Exception:
9+
710
def load_dotenv(*_args, **_kwargs): # type: ignore
811
return False
912

13+
1014
def main():
1115
# Load environment variables from .env file in the repo root
1216
dotenv_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env")
@@ -20,7 +24,7 @@ def main():
2024
parser.add_argument("--output-file", required=True)
2125
args = parser.parse_args()
2226

23-
with open(args.prompt_file, 'r') as f:
27+
with open(args.prompt_file) as f:
2428
prompt = f.read()
2529

2630
api_key = None
@@ -30,15 +34,13 @@ def main():
3034
api_key = os.getenv("OPENAI_API_KEY")
3135

3236
agent = deepagent.FlexibleAgent(
33-
provider=args.provider,
34-
api_key=api_key,
35-
model=args.model,
36-
dry_run=False
37+
provider=args.provider, api_key=api_key, model=args.model, dry_run=False
3738
)
3839
response = agent.run(prompt)
3940

40-
with open(args.output_file, 'w') as f:
41-
f.write(response.get('output', ''))
41+
with open(args.output_file, "w") as f:
42+
f.write(response.get("output", ""))
43+
4244

4345
if __name__ == "__main__":
4446
main()

0 commit comments

Comments
 (0)