From bdfed77cb1262a34cb1b861a5cc4d5b2e1eb4e4f Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Thu, 29 Jan 2026 16:42:53 -0600 Subject: [PATCH] Remove dead code from pypi_proxy.py - Remove unused imports (UpstreamClient, UpstreamClientConfig, UpstreamHTTPError, UpstreamConnectionError, UpstreamTimeoutError) - Simplify matched_source selection logic, removing dead conditional that always evaluated to True due to 'or True' --- backend/app/pypi_proxy.py | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/backend/app/pypi_proxy.py b/backend/app/pypi_proxy.py index c6f225f..aba1613 100644 --- a/backend/app/pypi_proxy.py +++ b/backend/app/pypi_proxy.py @@ -19,13 +19,6 @@ from sqlalchemy.orm import Session from .database import get_db from .models import UpstreamSource, CachedUrl, Artifact, Project, Package, Tag from .storage import S3Storage, get_storage -from .upstream import ( - UpstreamClient, - UpstreamClientConfig, - UpstreamHTTPError, - UpstreamConnectionError, - UpstreamTimeoutError, -) from .config import get_env_upstream_sources logger = logging.getLogger(__name__) @@ -360,18 +353,10 @@ async def pypi_download_file( # Not cached - fetch from upstream sources = _get_pypi_upstream_sources(db) - # Find a source that matches the upstream URL - matched_source = None - for source in sources: - source_url = getattr(source, 'url', '') - # Check if the upstream URL could come from this source - # (This is a loose check - the URL might be from files.pythonhosted.org) - if urlparse(upstream_url).netloc in source_url or True: # Allow any source for now - matched_source = source - break - - if not matched_source and sources: - matched_source = sources[0] # Use first source for auth if available + # Use the first available source for authentication headers + # Note: The upstream URL may point to files.pythonhosted.org or other CDNs, + # not the configured source URL directly, so we can't strictly validate the host + matched_source = sources[0] if sources else None try: headers = {"User-Agent": "Orchard-PyPI-Proxy/1.0"}