Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 3.41 KB

File metadata and controls

78 lines (56 loc) · 3.41 KB

TODO: Code Maturity Recommendations

Summary

Metric Value
Core lines (non-generated) ~1,180
Unit tests 211
Coverage (core) 95.8%
Cyclomatic complexity ceiling 42 (async _request)
Python versions 3.11-3.14

The project is production-grade. Generated API stubs are correctly excluded from coverage. The remaining issues are concentrated in rest_session.py and its async mirror.


Parallel Work (DONE)

All 8 parallel tasks completed. 211 tests pass, 95.8% coverage, no warnings.

  • Fix RuntimeWarning in async tests (replaced AsyncMock with _AwaitableValue wrapper)
  • Raise coverage floor from 60% to 90% (pyproject.toml)
  • Fix bare print() in production code (now uses self._logger.warning(...))
  • Remove dead get_pages pass-through method (confirmed dead, removed)
  • Remove unused F401 import (added # noqa: F401)
  • Consolidate line-length standard (ruff now uses 127 via pyproject.toml)
  • Dependabot config updated (changed to "uv" ecosystem)
  • Add integration test for async client (tests/integration/test_async_dashboard_api.py)

Linear Work (sequential, each step builds on the previous)

Order matters. Later items depend on or conflict with earlier ones.

Stream 1: Complexity Reduction (do in order)

  1. Reduce AsyncRestSession._request complexity (42)

    • File: meraki/aio/rest_session.py:140
    • Extract status-code handlers into discrete methods (match 429, match 5xx, etc.)
    • Sync version (rest_session.py:212, complexity 12) already partially does this with handle_4xx_errors; apply same pattern to async
  2. Reduce _get_pages_legacy complexity (24 sync, 19 async)

    • Files: rest_session.py:526, aio/rest_session.py:432
    • Split event-log-specific pagination logic into a helper or strategy
    • The "append results depending on endpoint type" block (lines 607-630) is doing three unrelated things
  3. Eliminate sync/async code duplication

    • rest_session.py (670 lines) and aio/rest_session.py (547 lines) share ~80% identical logic
    • Do this AFTER complexity reduction so you're deduplicating clean code, not spaghetti
    • Consider a shared base or code-generation approach (the generator already exists for API stubs)

Stream 2: Type Safety (do in order)

  1. Add type annotations to core modules

    • rest_session.py, aio/rest_session.py, __init__.py, exceptions.py have zero type hints
    • Enables mypy --strict or pyright in CI
  2. Add py.typed marker

    • Signals to downstream consumers that the package supports type checking
    • Only meaningful after annotations exist

Stream 3: Coverage Gap Fill (do after Stream 1)

  1. Cover the 36 missing lines
    • rest_session.py (25 lines): mostly logger-guarded branches and simulate path
    • aio/rest_session.py (6 lines): similar pattern
    • __init__.py (5 lines): lines 146-151 (logging edge case)
    • Wait until after complexity refactors so you're not writing tests for code that's about to move

Future (next major version consideration)

  • Consider httpx to unify sync/async
    • httpx provides both sync and async from one client, eliminating the dual-session architecture
    • Breaking change; only worth it at next major version
    • Would obsolete Stream 1 step 3 (deduplication), so decide before investing there