Skip to content

chore: hoist urllib.parse imports to module top#60

Merged
jackparnell merged 1 commit into
mainfrom
chore/hoist-urllib-imports
May 27, 2026
Merged

chore: hoist urllib.parse imports to module top#60
jackparnell merged 1 commit into
mainfrom
chore/hoist-urllib-imports

Conversation

@ColonistOne
Copy link
Copy Markdown
Collaborator

Summary

Cleanup sweep flagged in the PR #56 review, shipped ahead of the next release so the version bump bakes it in.

Both clients accumulated inline from urllib.parse import urlencode (and one quote) inside individual method bodies as the group-DM surface grew. None are conditional or lazy — they all fire on first call regardless. Hoist them to the module top to match the rest of the import block.

  • src/colony_sdk/client.py — strip 7 inline imports (6 urlencode + 1 quote). Top-level already had urlencode; extended to import quote alongside.
  • src/colony_sdk/async_client.py — strip 22 inline imports (21 urlencode + 1 quote). Add a new top-level from urllib.parse import quote, urlencode.

No behaviour change. Net: +2 / -57 lines.

Test plan

  • ruff check src/ tests/ clean
  • ruff format --check src/ tests/ clean
  • mypy src/ clean (no new errors)
  • pytest -q — 661 passed, 138 skipped (full unit suite)
  • pytest tests/integration/test_async.py against the real API — 27 passed, 3 skipped (no regression in async transport)
  • Group-DM integration tests deferred this run — burned the 12/hour create-group budget on probe runs earlier today. The cleanup doesn't touch group-DM code paths beyond import hoisting; will re-verify when the rate-limit window resets.

Per the TheColonyCC/* convention, holding the merge button for a human reviewer.

🤖 Generated with Claude Code

Both clients accumulated inline ``from urllib.parse import urlencode``
(and one ``quote``) inside individual method bodies as the group-DM
surface grew over PRs #56-#58. None are conditional or lazy — they
all fire at first method-call regardless. Hoist them to the module
top to match the rest of the import block.

- src/colony_sdk/client.py — strip 7 inline imports (6 urlencode + 1
  quote). Top-level already had ``urlencode``; extend it to import
  ``quote`` alongside.
- src/colony_sdk/async_client.py — strip 22 inline imports (21
  urlencode + 1 quote). Add a new top-level
  ``from urllib.parse import quote, urlencode``.

No behaviour change. Net: -27 lines.

Flagged in the PR #56 review as worth a "separate cleanup sweep
someday". Doing it now ahead of the next release so the version
bump ships with the cleanup baked in.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jackparnell jackparnell merged commit 33d270b into main May 27, 2026
7 checks passed
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.

2 participants