Skip to content

feat: proxybroker as a service - #210

Open
ngctnnnn wants to merge 1 commit into
constverum:masterfrom
ngctnnnn:master
Open

feat: proxybroker as a service#210
ngctnnnn wants to merge 1 commit into
constverum:masterfrom
ngctnnnn:master

Conversation

@ngctnnnn

Copy link
Copy Markdown

Hosting proxybroker as a service for scalable applications

dannyeuu pushed a commit to dannyeuu/ProxyBroker that referenced this pull request May 12, 2026
…op() (constverum#210)

Closes constverum#203 — refactor remaining stdlib deprecation sites flagged for Python 3.14+/3.16 compatibility, plus enable lint-time prevention of the encoding= class of bug surfaced during review.

## Deprecation fixes

**`argparse.FileType` → deferred open via ExitStack** (`cli.py`)
- `--data` (find/serve): `FileType("r")` → path string, opened in `cli()` with `encoding="utf-8"`
- `--outfile` (find/grab): `FileType("w", 1)` → path string, opened with `buffering=1, encoding="utf-8"` (line-buffered preserved)
- Stdin/stdout via `-` preserved per `argparse.FileType` original semantics
- Empty paths now error visibly instead of silently falling back (per codex review)

**`asyncio.get_event_loop()` → `asyncio.get_running_loop()`** (`proxy.py`)
- Two call sites inside `_start_tls` upgrade path; both inside async coroutines so running loop is guaranteed

## Lint-time prevention

- Enable ruff `PLW1514` (`unspecified-encoding`) in lint config to catch the `open()`-without-`encoding=` class of bug going forward
- Pin `select` to make ruleset explicit; scope preview-rule selection via `explicit-preview-rules`
- Fix 9 existing PLW1514 violations in `examples/` (3) and `tests/` (6)
- Drop redundant `import os` in `utils.py` (surfaced by F401 default rule)

## Out of scope

- `cli.py:12 set_event_loop_policy(WindowsSelectorEventLoopPolicy())` — Python 3.16 removes the policy system entirely. Tracked in #228 (needs Windows-specific testing).

## Verification

- 293/293 tests pass locally; all 24 CI checks green
- Verified against [Python 3.14 docs](https://docs.python.org/3.14/library/argparse.html): `argparse.FileType` deferred-open pattern matches the recommended replacement exactly
- Matrix audit: (command × file flag × value) and (Proxy.connect call site × loop state) — all cells handled correctly

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant