Skip to content

Commit 0663d37

Browse files
authored
Merge pull request #167 from AndreiDrang/main
Tests improvements
2 parents d4b3f65 + 04e1377 commit 0663d37

16 files changed

Lines changed: 628 additions & 40 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v6
3131
- name: Set up uv
32-
uses: astral-sh/setup-uv@v5
32+
uses: astral-sh/setup-uv@v7
3333
with:
3434
enable-cache: true
3535
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/build_sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v6
1818
- name: Set up uv
19-
uses: astral-sh/setup-uv@v5
19+
uses: astral-sh/setup-uv@v7
2020
with:
2121
enable-cache: true
2222
- name: Set up Python 3.11

.github/workflows/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v6
3131
- name: Set up uv
32-
uses: astral-sh/setup-uv@v5
32+
uses: astral-sh/setup-uv@v7
3333
with:
3434
enable-cache: true
3535
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@v6
3333
- name: Set up uv
34-
uses: astral-sh/setup-uv@v5
34+
uses: astral-sh/setup-uv@v7
3535
with:
3636
enable-cache: true
3737
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v6
1818
- name: Set up uv
19-
uses: astral-sh/setup-uv@v5
19+
uses: astral-sh/setup-uv@v7
2020
with:
2121
enable-cache: true
2222
- name: Set up Python 3.11

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v6
3636
- name: Set up uv
37-
uses: astral-sh/setup-uv@v5
37+
uses: astral-sh/setup-uv@v7
3838
with:
3939
enable-cache: true
4040
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/zai-code-bot.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Z.ai Code Bot
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
10+
branches:
11+
- main
12+
- prod
13+
issue_comment:
14+
types:
15+
- created
16+
pull_request_review_comment:
17+
types:
18+
- created
19+
20+
permissions:
21+
contents: read
22+
pull-requests: write
23+
issues: write
24+
25+
concurrency:
26+
group: zai-bot-${{ github.event.pull_request.number }}
27+
cancel-in-progress: true
28+
29+
jobs:
30+
zai-bot:
31+
if: |
32+
(github.event_name == 'pull_request' && github.event.pull_request.draft == false) ||
33+
(github.event_name == 'issue_comment' && github.event.issue.pull_request) ||
34+
(github.event_name == 'pull_request_review_comment' && github.event.pull_request.draft == false)
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v6
39+
40+
- name: Run Z.ai Bot
41+
uses: AndreiDrang/zai-code-bot@main
42+
with:
43+
ZAI_API_KEY: ${{ secrets.ZAI_API_KEY }}
44+
ZAI_MODEL: ${{ vars.ZAI_MODEL || 'glm-5' }}
45+
GITHUB_TOKEN: ${{ github.token }}

AGENTS.md

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,72 @@
11
# PROJECT KNOWLEDGE BASE
22

3-
**Generated:** 2026-01-13
3+
**Generated:** 2026-03-15
4+
**Commit:** b797332
5+
**Branch:** main
46

57
## OVERVIEW
6-
Python 3.8+ library for Capsolver service API. Supports both synchronous (`requests`) and asynchronous (`aiohttp`) operations. Uses `msgspec` for high-performance JSON serialization.
8+
Python 3.8+ library for Capsolver service API. Dual sync (`requests`) / async (`aiohttp`) support. `msgspec` for serialization, `tenacity` for retries.
79

810
## STRUCTURE
911
```
1012
./
11-
├── src/python3_capsolver/ # Main library package
12-
│ ├── core/ # Base classes, serializers, instruments
13-
│ └── *.py # Service-specific implementations (ReCaptcha, Cloudflare, etc.)
14-
├── tests/ # Pytest suite
15-
└── docs/ # Sphinx documentation
13+
├── src/python3_capsolver/ # Main library (service implementations)
14+
│ ├── core/ # Base classes, instruments, serializers
15+
│ └── *.py # Service-specific (ReCaptcha, Cloudflare, etc.)
16+
├── tests/ # Pytest suite (matches source structure)
17+
├── docs/ # Sphinx documentation
18+
├── ARCHITECTURE.md # System architecture (matklad-style)
19+
└── pyproject.toml # Build, uv, pytest, black/isort config
1620
```
1721

1822
## WHERE TO LOOK
1923
| Task | Location | Notes |
2024
|------|----------|-------|
21-
| **Base Logic** | `src/python3_capsolver/core/` | `base.py`, `serializer.py`, `enum.py` |
22-
| **Service Implementations** | `src/python3_capsolver/*.py` | `recaptcha.py`, `cloudflare.py`, etc. |
23-
| **Tests** | `tests/` | Matches source structure |
24-
| **Configuration** | `pyproject.toml` | Build, dependency, tool config |
25+
| **Architecture** | `ARCHITECTURE.md` | Layered design, invariants, life of a request |
26+
| **Base Logic** | `src/python3_capsolver/core/` | `base.py`, `serializer.py`, `enum.py`, instruments |
27+
| **Service Implementations** | `src/python3_capsolver/*.py` | `recaptcha.py`, `cloudflare.py`, `control.py` |
28+
| **Tests** | `tests/` | `conftest.py` (BaseTest, fixtures), per-service tests |
29+
| **Configuration** | `pyproject.toml` | uv, black (120), isort, pytest (asyncio auto) |
30+
| **Commands** | `Makefile` | `make tests`, `make build`, `make upload` |
2531

2632
## CONVENTIONS
27-
- **Formatter**: `black` (line-length 120), `isort` (profile "black").
28-
- **Serialization**: `msgspec` preferred over `json` for performance.
29-
- **Concurrency**: Dual support (Sync/Async) required for all instruments.
30-
- **Retries**: `tenacity` library used for resilience.
33+
- **Toolchain**: `uv` for package management (`uv sync`, `uv run`, `uv build`, `uv publish`)
34+
- **Formatter**: `black` (line-length 120), `isort` (profile "black")
35+
- **Cleanup**: `autoflake` (remove unused imports/variables)
36+
- **Serialization**: `msgspec` (not `json`) for performance
37+
- **Concurrency**: Dual sync/async required for all instruments
38+
- **Retries**: `tenacity` (async), `requests.Retry` (sync) — 5 attempts, exponential backoff
39+
- **Testing**: pytest 7.0+, `pytest-asyncio` (auto mode), rate-limiting fixtures (1s func, 2s class)
40+
41+
## ANTI-PATTERNS (THIS PROJECT)
42+
- **Empty `__init__.py` files**: `src/python3_capsolver/__init__.py` only exports `__version__`; `core/__init__.py` is completely empty. Users must import via full paths (`from python3_capsolver.recaptcha import ReCaptcha`)
43+
- **AGENTS.md in package dirs**: Will ship with distribution unless excluded in `pyproject.toml`
44+
- **No CLI entry points**: Library-only, no console_scripts defined
45+
46+
## UNIQUE STYLES
47+
- **Service Pattern**: Each captcha service inherits from `CaptchaParams` with `captcha_handler()` (sync) + `aio_captcha_handler()` (async)
48+
- **Task Payload**: Dict merged with internal params, passed to `create_task()` API
49+
- **Context Managers**: All services support `with` / `async with` for session cleanup
50+
- **Test Duplication**: Every sync test (`def test_*`) has async counterpart (`async def test_aio_*`)
3151

3252
## COMMANDS
3353
```bash
34-
make tests # Run test suite
35-
pip install . # Install package locally
54+
# Development
55+
uv sync --all-groups # Install all dependencies
56+
uv run pytest tests/ # Run tests
57+
uv run black src/ tests/ # Format
58+
uv run isort src/ tests/ # Sort imports
59+
60+
# Build & Publish
61+
uv build # Build wheel/sdist
62+
uv publish # Upload to PyPI
63+
64+
# Documentation
65+
cd docs/ && uv run --group docs make html -e
3666
```
3767

3868
## NOTES
39-
- Dependencies: `requests`, `aiohttp`, `msgspec`, `tenacity`.
40-
- Requires `API_KEY` in environment for tests.
41-
69+
- **API Key**: Tests require `API_KEY` environment variable
70+
- **Coverage**: HTML reports in `coverage/html/`, XML in `coverage/coverage.xml`
71+
- **Python Support**: 3.8–3.12 (tested via `target-version = ['py310']`)
72+
- **Dependencies**: `requests>=2.21.0`, `aiohttp>=3.9.2`, `msgspec>=0.18,<=0.21`, `tenacity>=8,<10`

0 commit comments

Comments
 (0)