Skip to content

Commit 5f2df54

Browse files
chore: major linting and code style cleanup (143 fixes)
1 parent d87f49f commit 5f2df54

27 files changed

+585
-271
lines changed

examples/example_ask.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
questions = [
1617
"What are new treatments for Alzheimer's?",
1718
"clinical trials for diabetes",
1819
"latest research on CRISPR",
19-
"tell me about ibuprofen"
20+
"tell me about ibuprofen",
2021
]
21-
22+
2223
try:
2324
with MedKit(debug=True) as med:
2425
for q in questions:
2526
print(f"\n>>> Question: {q}")
2627
res = med.ask(q)
2728
print(f"Result type: {type(res).__name__}")
28-
29+
2930
except MedKitError as e:
3031
print(f"Error: {e}")
3132

33+
3234
if __name__ == "__main__":
3335
main()

examples/example_async.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Example of using the asynchronous MedKit SDK.
33
"""
44

5-
import sys
65
import asyncio
6+
import sys
77
from pathlib import Path
88

99
# Add project root to sys.path
@@ -12,24 +12,26 @@
1212
from medkit import AsyncMedKit
1313
from medkit.exceptions import MedKitError
1414

15+
1516
async def main():
1617
query = "diabetes"
1718
try:
1819
async with AsyncMedKit() as med:
1920
print(f"Async search for '{query}'...")
2021
results = await med.search(query)
21-
22+
2223
print(f"\n--- Results for {query} ---")
2324
print(f"Drugs found: {len(results.drugs)}")
2425
print(f"Papers found: {len(results.papers)}")
2526
print(f"Trials found: {len(results.trials)}")
26-
27+
2728
if results.papers:
2829
print("\nTop Paper:")
2930
print(f"- {results.papers[0].title}")
30-
31+
3132
except MedKitError as e:
3233
print(f"Error: {e}")
3334

35+
3436
if __name__ == "__main__":
3537
asyncio.run(main())

examples/example_drugs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
try:
1617
with MedKit() as med:
1718
print("Fetching info for 'ibuprofen'...")
1819
info = med.drug("ibuprofen")
19-
20+
2021
print(f"Brand Name: {info.brand_name}")
2122
print(f"Generic Name: {info.generic_name}")
2223
print(f"Manufacturer: {info.manufacturer}")
@@ -26,5 +27,6 @@ def main():
2627
except MedKitError as e:
2728
print(f"Error: {e}")
2829

30+
2931
if __name__ == "__main__":
3032
main()

examples/example_explain.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,41 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
query = "diabetes"
1617
try:
1718
with MedKit() as med:
1819
print(f"Generating comprehensive report for '{query}'...")
1920
explanation = med.explain_drug(query)
20-
21+
2122
if explanation.drug_info:
2223
print("\n=== FDA Information ===")
2324
print(f"Brand Name: {explanation.drug_info.brand_name}")
2425
print(f"Generic Name: {explanation.drug_info.generic_name}")
2526
else:
2627
print("\n=== FDA Information ===")
2728
print(f"No FDA info found for '{query}'")
28-
29+
2930
if explanation.papers:
3031
print(f"\n=== Research Papers (Top {len(explanation.papers)}) ===")
3132
for i, p in enumerate(explanation.papers, 1):
3233
print(f"{i}. {p.title} ({p.year})")
3334
else:
3435
print("\n=== Research Papers ===")
3536
print("No recent papers found")
36-
37+
3738
if explanation.trials:
38-
print(f"\n=== Clinical Trials ===")
39+
print("\n=== Clinical Trials ===")
3940
for t in explanation.trials:
4041
print(f"- {t.title} [{t.status}]")
4142
else:
4243
print("\n=== Clinical Trials ===")
4344
print("No active recruiting trials found")
44-
45+
4546
except MedKitError as e:
4647
print(f"Error: {e}")
4748

49+
4850
if __name__ == "__main__":
4951
main()

examples/example_graph.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
query = "diabetes"
1617
try:
1718
with MedKit() as med:
1819
print(f"Building medical relationship graph for '{query}'...")
1920
graph = med.graph(query)
20-
21+
2122
print(f"\nNodes found: {len(graph.nodes)}")
2223
print(f"Relationships found: {len(graph.edges)}")
23-
24+
2425
print("\nRelationships:")
2526
for edge in graph.edges[:10]:
2627
print(f"- {edge.source} --({edge.relationship})--> {edge.target}")
27-
28+
2829
except MedKitError as e:
2930
print(f"Error: {e}")
3031

32+
3133
if __name__ == "__main__":
3234
main()

examples/example_papers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
try:
1617
with MedKit() as med:
1718
print("Searching for recent papers on 'CRISPR'...")
1819
papers = med.papers("CRISPR", limit=5)
19-
20+
2021
for paper in papers:
2122
print(f"\nTitle: {paper.title}")
2223
print(f"Journal: {paper.journal} ({paper.year})")
@@ -25,5 +26,6 @@ def main():
2526
except MedKitError as e:
2627
print(f"Error: {e}")
2728

29+
2830
if __name__ == "__main__":
2931
main()

examples/example_plugin.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from medkit import MedKit
1313
from medkit.providers.base import BaseProvider
1414

15+
1516
class MyHospitalProvider(BaseProvider):
1617
def __init__(self):
1718
super().__init__(name="hospital")
@@ -20,26 +21,28 @@ def search_sync(self, query: str, **kwargs) -> dict[str, Any]:
2021
return {
2122
"source": "Local Hospital Database",
2223
"patient_count": 120,
23-
"query": query
24+
"query": query,
2425
}
2526

27+
2628
def main():
2729
try:
2830
med = MedKit(debug=True)
29-
31+
3032
# Register the plugin
3133
med.register_provider(MyHospitalProvider())
32-
34+
3335
# Query the plugin (via some generic search or direct provider access)
3436
# For now, let's just see if it's in the list
3537
print(f"Registered providers: {list(med._providers.keys())}")
36-
38+
3739
# Direct query test
3840
res = med._providers["hospital"].search_sync("diabetes")
3941
print(f"Plugin result: {res}")
40-
42+
4143
except Exception as e:
4244
print(f"Error: {e}")
4345

46+
4447
if __name__ == "__main__":
4548
main()

examples/example_search.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,32 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
query = "insulin"
1617
try:
1718
with MedKit() as med:
1819
print(f"Searching for '{query}' across all sources...")
1920
results = med.search(query)
20-
21+
2122
if results.drugs:
2223
print("\n=== Found Drugs ===")
2324
for d in results.drugs:
2425
print(f"Drug: {d.brand_name} ({d.generic_name})")
25-
26+
2627
if results.papers:
2728
print(f"\n=== Research Papers (Top {len(results.papers)}) ===")
2829
for i, p in enumerate(results.papers, 1):
2930
print(f"{i}. {p.title} ({p.year})")
30-
31+
3132
if results.trials:
3233
print(f"\n=== Clinical Trials ({len(results.trials)}) ===")
3334
for t in results.trials:
3435
print(f"- {t.nct_id}: {t.status} - {t.title}")
35-
36+
3637
except MedKitError as e:
3738
print(f"Error: {e}")
3839

40+
3941
if __name__ == "__main__":
4042
main()

examples/example_summary.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,39 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
query = "diabetes"
1617
try:
1718
with MedKit() as med:
1819
print(f"Generating medical summary for '{query}'...")
1920
summary = med.summary(query)
20-
21+
2122
print(f"\nCondition: {summary.condition.capitalize()}")
22-
23+
2324
if summary.drugs:
2425
print("\nDrugs:")
2526
for drug in summary.drugs:
2627
print(f"- {drug}")
27-
28+
2829
if summary.papers:
2930
years = [p.year for p in summary.papers if p.year]
3031
year_range = f" ({max(years)}{min(years)})" if years else ""
3132
print(f"\nLatest Research{year_range}:")
3233
for p in summary.papers:
3334
print(f"- {p.title} ({p.year})")
34-
35+
3536
if summary.trials:
3637
print("\nClinical Trials:")
3738
for t in summary.trials:
3839
print(f"- {t.nct_id}: {t.status} - {t.title}")
3940
else:
4041
print("\nClinical Trials:")
4142
print("No active recruiting trials found")
42-
43+
4344
except MedKitError as e:
4445
print(f"Error: {e}")
4546

47+
4648
if __name__ == "__main__":
4749
main()

examples/example_trials.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
from medkit import MedKit
1212
from medkit.exceptions import MedKitError
1313

14+
1415
def main():
1516
try:
1617
with MedKit() as med:
1718
print("Searching for recruiting clinical trials for 'breast cancer'...")
1819
# We specifically request recruiting trials
1920
trials = med.trials("breast cancer", recruiting=True, limit=5)
20-
21+
2122
for trial in trials:
2223
print(f"\nTrial: {trial.title}")
2324
print(f"ID: {trial.nct_id}")
@@ -27,5 +28,6 @@ def main():
2728
except MedKitError as e:
2829
print(f"Error: {e}")
2930

31+
3032
if __name__ == "__main__":
3133
main()

0 commit comments

Comments
 (0)