Skip to content

Commit 72df4ee

Browse files
committed
refactor: Clean up string concatenation and fix comment formatting
1 parent 0b2fce5 commit 72df4ee

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

AGENTS.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ This file provides guidance to agents when working with code in this repository.
55
## General Guidelines
66

77
1. Modern Python First: Use Python 3.12+ features extensively - built-in generics, pattern matching, and dataclasses.
8-
2. Async-First Architecture: All I/O operations must be async. Use modern async patterns like `asyncio.TaskGroup` for concurrency.
9-
3. Type Safety: Full type annotations on all functions including return types. Use modern syntax (`dict[str, int]`, `str | None`).
10-
4. KISS Principle: Aim for simplicity and clarity. Avoid unnecessary abstractions or metaprogramming.
11-
5. DRY with Care: Reuse code appropriately but avoid over-engineering. Each command handler has single responsibility.
12-
6. Performance-Conscious: Use `@dataclass(slots=True)` when object count justifies it, orjson for JSON, and async-safe patterns over explicit locks.
8+
2. KISS Principle: Aim for simplicity and clarity. Avoid unnecessary abstractions or metaprogramming.
9+
3. DRY with Care: Reuse code appropriately but avoid over-engineering. Each command handler has single responsibility.
1310

14-
## Activate venv before any test execution
11+
## Test after any change
1512

16-
Unit test located in `tests/` directory
13+
1. Activate venv before any test execution:
1714

1815
```bash
1916
source .venv/bin/activate
20-
pytest -v -qa --strict-markers
17+
```
18+
19+
2. Run pytest with following command to ensure all tests pass:
20+
21+
```bash
22+
pytest -v -q --strict-markers
2123
```
2224

2325
## Run the application
@@ -27,10 +29,3 @@ python run.py --help
2729
python run.py install appflowy
2830
python run.py update appflowy
2931
```
30-
31-
## More information about cli
32-
33-
- Read developers.md for an overview of the architecture, api structure etc.
34-
- [docs/developers.md](docs/developers.md)
35-
- Read wiki for detailed information about configuration, commands etc.
36-
- [docs/wiki.md](docs/wiki.md)

my_unicorn/github_client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
information, extract AppImage assets, and manage GitHub-specific operations.
55
"""
66

7-
import re
87
from dataclasses import dataclass
98
from typing import Any, TypedDict, cast
109
from urllib.parse import urlparse
@@ -17,8 +16,8 @@
1716
from .services.progress import get_progress_service
1817
from .utils import (
1918
extract_and_validate_version,
20-
is_checksum_file,
2119
get_checksum_file_format_type,
20+
is_checksum_file,
2221
)
2322

2423
logger = get_logger(__name__)
@@ -198,6 +197,7 @@ async def _try_fetch_stable_release(
198197
199198
Raises:
200199
aiohttp.ClientError: If there are actual API/network errors
200+
201201
"""
202202
try:
203203
# Check cache first (unless bypassed)
@@ -289,6 +289,7 @@ async def _try_fetch_prerelease(
289289
290290
Raises:
291291
aiohttp.ClientError: If there are actual API/network errors
292+
292293
"""
293294
try:
294295
# Check cache first (unless bypassed)
@@ -699,7 +700,7 @@ def extract_appimage_assets(self, release_data: GitHubReleaseDetails) -> list[Gi
699700
if asset["name"].endswith(".AppImage") or asset["name"].endswith(".appimage")
700701
]
701702

702-
#FIXME: too many branches
703+
# FIXME: too many branches
703704
def select_best_appimage(
704705
self,
705706
release_data: GitHubReleaseDetails,
@@ -793,7 +794,7 @@ def select_best_appimage(
793794
# Fallback: return first candidate
794795
return candidates[0]
795796

796-
#FIXME: unused, move the auth or make this to check the available rate status
797+
# FIXME: unused, move the auth or make this to check the available rate status
797798
# and use in the github api requests to prevent limit errors
798799
async def check_rate_limit(self) -> dict[str, Any]:
799800
"""Check current rate limit status.
@@ -810,7 +811,7 @@ async def check_rate_limit(self) -> dict[str, Any]:
810811
data = await response.json()
811812
return data
812813

813-
#FIXME: unused? checkout parser.py or url install template method
814+
# FIXME: unused? checkout parser.py or url install template method
814815
@staticmethod
815816
def parse_repo_url(repo_url: str) -> tuple[str, str]:
816817
"""Parse GitHub repository URL to extract owner and repo.
@@ -868,7 +869,7 @@ async def get_default_branch(self) -> str:
868869
f"Fetched default branch for {self.owner}/{self.repo}"
869870
)
870871

871-
#FIXME: return str not Any
872+
# FIXME: return str not Any
872873
return data.get("default_branch", "main")
873874

874875
def build_icon_url(self, icon_path: str, branch: str | None = None) -> str:

my_unicorn/self_update.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ async def get_latest_release(self) -> dict[str, Any] | None:
163163
if e.status == HTTP_FORBIDDEN:
164164
logger.error("GitHub API rate limit exceeded")
165165
print(
166-
"GitHub Rate limit exceeded. Please try again later within 1 hour "
167-
+ "or use different network/VPN."
166+
"".join(
167+
[
168+
"GitHub Rate limit exceeded. Please try again later ",
169+
"within 1 hour or use different network/VPN.",
170+
]
171+
)
168172
)
169173
else:
170174
logger.error("GitHub API error: %s", e)
@@ -195,8 +199,12 @@ async def check_for_update(self) -> bool:
195199
if not latest_version_tag:
196200
logger.error("Malformed release data - no tag_name found")
197201
print(
198-
"Malformed release data! Reinstall manually or "
199-
+ "open an issue on GitHub for help!"
202+
"".join(
203+
[
204+
"Malformed release data! Reinstall manually or ",
205+
"open an issue on GitHub for help!",
206+
]
207+
)
200208
)
201209
return False
202210

0 commit comments

Comments
 (0)