Skip to content

Apply coding best practices: strict mypy, remove future annotations, fix async concurrency, hoist imports#7

Merged
codeSamuraii merged 1 commit into
mainfrom
copilot/apply-coding-best-practices-yet-again
Apr 16, 2026
Merged

Apply coding best practices: strict mypy, remove future annotations, fix async concurrency, hoist imports#7
codeSamuraii merged 1 commit into
mainfrom
copilot/apply-coding-best-practices-yet-again

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown

Applies coding best practices across the codebase: strict mypy compliance, proper import placement, removal of unnecessary from __future__ import annotations, and fixing a sequential async pattern that prevented concurrent execution.

mypy strict: 7 errors → 0

  • _protocol.py: explicit int annotation on decode_header to fix no-any-return
  • worker.py, remote.py: assert guards before accessing nullable _sandbox
  • remote.py: TYPE_CHECKING import for DockerSandbox forward reference
  • redis.py: type: ignore[import-not-found] for optional dependency

Remove from __future__ import annotations

Removed from docker.py and guest_agent.py. Project targets >=3.10 so PEP 604 unions work at runtime. String annotations already in place where needed (__aenter__).

Hoist imports

  • __main__.py: import shutil moved to top (was duplicated inline in 3 CLI handlers)
  • docker.py: _progress_callback import moved to top (no circular dep risk)

Fix async concurrency in .map()

_make_map_method was awaiting submissions and results sequentially, defeating the purpose of batch execution:

# Before — sequential
results = [await start_method(*args, **kwargs) for args in args_list]
return [await r for r in results]

# After — concurrent via gather
coros = [cast(Awaitable[object], start_method(*args, **kwargs)) for args in args_list]
results = await asyncio.gather(*coros)
awaitables = [cast(Awaitable[object], r) for r in results]
return list(await asyncio.gather(*awaitables))

Both phases (submit all tasks, then collect all results) now run concurrently.

…ns, improve async concurrency, hoist imports

Agent-Logs-Url: https://github.com/codeSamuraii/pyfuse/sessions/b525c00f-293b-4d49-8924-ad15d185248a

Co-authored-by: codeSamuraii <17270548+codeSamuraii@users.noreply.github.com>
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