Skip to content

Commit 7288177

Browse files
committed
Fix testing crashed tests
1 parent 63312f8 commit 7288177

4 files changed

Lines changed: 27 additions & 21 deletions

File tree

forklet/core/orchestrator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .progress_tracker import ProgressTracker
2525
from .state_controller import StateController
2626

27+
from forklet.infrastructure import RateLimitInfo
2728
from forklet.infrastructure.logger import logger
2829

2930

forklet/infrastructure/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from .error_handler import (
2-
DownloadError, RateLimitError, RateLimitError,
2+
DownloadError, RateLimitError,
33
AuthenticationError, RepositoryNotFoundError,
44
handle_api_error, retry_on_error
55
)
66

7-
from .rate_limiter import RateLimiter
7+
from .rate_limiter import RateLimiter, RateLimitInfo
88
from .retry_manager import RetryManager
9+
from .cache_manager import CacheManager, CacheEntry
910

1011
__all__ = [
11-
DownloadError, RateLimitError, RateLimitError,
12+
DownloadError, RateLimitError,
1213
AuthenticationError, RepositoryNotFoundError,
1314
handle_api_error, retry_on_error, RateLimiter,
14-
RetryManager
15+
RetryManager, RateLimitInfo, CacheManager, CacheEntry
1516
]

forklet/models/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from datetime import datetime
1212
from enum import Enum
1313
from pathlib import Path
14-
from typing import Dict, List, Optional, Set
14+
from typing import Dict, List, Optional, Set, Any
1515

1616
from .github import RepositoryInfo, GitReference
1717

forklet/services/github_api.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
Service for interacting with GitHub API with rate limiting and error handling.
33
"""
44

5-
from typing import List, Optional, Dict, Any, AsyncIterator
6-
5+
from typing import List, Optional, Dict, Any, AsyncIterator, Callable
6+
import datetime
77
import asyncio
88
import httpx
99
from github import Github, GithubException
1010
# from github.Repository import Repository as GithubRepository
1111

12-
from ..infrastructure.rate_limiter import RateLimiter
13-
from ..infrastructure.retry_manager import RetryManager
14-
from ..infrastructure.error_handler import (
12+
# from ..infrastructure.rate_limiter import RateLimiter
13+
# from ..infrastructure.retry_manager import RetryManager
14+
from ..infrastructure import (
1515
handle_api_error,
1616
RateLimitError,
1717
RepositoryNotFoundError,
1818
DownloadError,
19+
RateLimiter,
20+
RetryManager,
21+
CacheManager,
22+
RateLimitInfo
1923
)
20-
from ..infrastructure.cache_manager import CacheManager
24+
# from ..infrastructure.cache_manager import CacheManager
2125
from ..models import RepositoryInfo, GitReference, RepositoryType, GitHubFile
2226
from ..models.constants import USER_AGENT
2327

@@ -75,19 +79,19 @@ def _on_rate_limit_update(self, rate_limit_info: RateLimitInfo) -> None:
7579
# Configure HTTP client
7680
headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": USER_AGENT}
7781

78-
if auth_token:
79-
headers["Authorization"] = f"token {auth_token}"
82+
if self.auth_token:
83+
headers["Authorization"] = f"token {self.auth_token}"
8084

8185
self.http_client = httpx.AsyncClient(
82-
headers=headers, timeout=httpx.Timeout(timeout)
86+
headers=headers, timeout=httpx.Timeout(self.timeout)
8387
)
8488

8589
# Sync client for PyGithub (used only for metadata)
8690
self.github_client = (
8791
Github(
88-
auth_token, retry=self.retry_manager.max_retries, user_agent=USER_AGENT
92+
self.auth_token, retry=self.retry_manager.max_retries, user_agent=USER_AGENT
8993
)
90-
if auth_token
94+
if self.auth_token
9195
else Github(retry=self.retry_manager.max_retries, user_agent=USER_AGENT)
9296
)
9397

@@ -129,19 +133,19 @@ async def update_rate_limit_info(self, headers: Dict[str, str]) -> None:
129133
# Configure HTTP client
130134
headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": USER_AGENT}
131135

132-
if auth_token:
133-
headers["Authorization"] = f"token {auth_token}"
136+
if self.auth_token:
137+
headers["Authorization"] = f"token {self.auth_token}"
134138

135139
self.http_client = httpx.AsyncClient(
136-
headers=headers, timeout=httpx.Timeout(timeout)
140+
headers=headers, timeout=httpx.Timeout(self.timeout)
137141
)
138142

139143
# Sync client for PyGithub (used only for metadata)
140144
self.github_client = (
141145
Github(
142-
auth_token, retry=self.retry_manager.max_retries, user_agent=USER_AGENT
146+
self.auth_token, retry=self.retry_manager.max_retries, user_agent=USER_AGENT
143147
)
144-
if auth_token
148+
if self.auth_token
145149
else Github(retry=self.retry_manager.max_retries, user_agent=USER_AGENT)
146150
)
147151

0 commit comments

Comments
 (0)