chore: upgrade all Python packages and fix linting issues

- Update all dependencies to latest versions (fastmcp, httpx, packaging, etc.)
- Downgrade click from yanked 8.2.2 to stable 8.1.7
- Fix code formatting and linting issues with ruff
- Most tests passing (2 test failures in dependency resolver need investigation)
This commit is contained in:
Ryan Malloy 2025-08-15 20:23:14 -06:00
parent 503ea589f1
commit 8b43927493
34 changed files with 2276 additions and 1593 deletions

View file

@ -2,44 +2,56 @@
"""Test script for the improved get_top_packages_by_downloads function."""
import asyncio
from pypi_query_mcp.tools.download_stats import get_top_packages_by_downloads
async def test_improved():
try:
result = await get_top_packages_by_downloads('month', 10)
print('✅ Success! Result keys:', list(result.keys()))
print(f'Number of packages returned: {len(result.get("top_packages", []))}')
print(f'Data source: {result.get("data_source")}')
print(f'Methodology: {result.get("methodology")}')
print('\nTop 5 packages:')
for i, pkg in enumerate(result.get('top_packages', [])[:5]):
downloads = pkg.get('downloads', 0)
stars = pkg.get('github_stars', 'N/A')
estimated = '(estimated)' if pkg.get('estimated', False) else '(real)'
github_enhanced = ' 🌟' if pkg.get('github_enhanced', False) else ''
print(f'{i+1}. {pkg.get("package", "N/A")} - {downloads:,} downloads {estimated}{github_enhanced}')
if stars != 'N/A':
print(f' GitHub: {stars:,} stars, {pkg.get("category", "N/A")} category')
result = await get_top_packages_by_downloads("month", 10)
print("✅ Success! Result keys:", list(result.keys()))
print(f"Number of packages returned: {len(result.get('top_packages', []))}")
print(f"Data source: {result.get('data_source')}")
print(f"Methodology: {result.get('methodology')}")
print("\nTop 5 packages:")
for i, pkg in enumerate(result.get("top_packages", [])[:5]):
downloads = pkg.get("downloads", 0)
stars = pkg.get("github_stars", "N/A")
estimated = "(estimated)" if pkg.get("estimated", False) else "(real)"
github_enhanced = " 🌟" if pkg.get("github_enhanced", False) else ""
print(
f"{i + 1}. {pkg.get('package', 'N/A')} - {downloads:,} downloads {estimated}{github_enhanced}"
)
if stars != "N/A":
print(
f" GitHub: {stars:,} stars, {pkg.get('category', 'N/A')} category"
)
# Test different periods
print('\n--- Testing different periods ---')
for period in ['day', 'week', 'month']:
print("\n--- Testing different periods ---")
for period in ["day", "week", "month"]:
result = await get_top_packages_by_downloads(period, 3)
top_3 = result.get('top_packages', [])
print(f'{period}: {len(top_3)} packages, avg downloads: {sum(p.get("downloads", 0) for p in top_3) // max(len(top_3), 1):,}')
print('\n--- Testing different limits ---')
top_3 = result.get("top_packages", [])
print(
f"{period}: {len(top_3)} packages, avg downloads: {sum(p.get('downloads', 0) for p in top_3) // max(len(top_3), 1):,}"
)
print("\n--- Testing different limits ---")
for limit in [5, 20, 50]:
result = await get_top_packages_by_downloads('month', limit)
packages = result.get('top_packages', [])
real_count = len([p for p in packages if not p.get('estimated', False)])
print(f'Limit {limit}: {len(packages)} packages returned, {real_count} with real stats')
result = await get_top_packages_by_downloads("month", limit)
packages = result.get("top_packages", [])
real_count = len([p for p in packages if not p.get("estimated", False)])
print(
f"Limit {limit}: {len(packages)} packages returned, {real_count} with real stats"
)
except Exception as e:
print(f'❌ Error: {e}')
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
if __name__ == '__main__':
asyncio.run(test_improved())
if __name__ == "__main__":
asyncio.run(test_improved())