Skip to content

Cleanup: assorted consistency & dead-code fixes (exhaustiveness, ExecHook provenance, type:ignore, lazy imports, en-GB, dead aliases) #129

Description

@lodyai

Summary

A cluster of small, individually-trivial consistency and dead-code fixes
surfaced by the refactoring audit. Grouped here as one gated cleanup; each is a
checklist item.

Tasks

  • get_stream_backend exhaustiveness (cuprum/_backend.py:148-165) —
    the match requested: has no case _ and no terminal raise, so a future
    enum member falls off the end returning None typed as StreamBackend. Add
    case _: raise AssertionError(f"unreachable backend {requested!r}").
  • ExecHook provenance (cuprum/__init__.py:45) — ExecHook is
    re-exported from cuprum.context though it is defined in cuprum.events:84,
    while ExecEvent is imported from cuprum.events. Import both from their
    definition site; drop ExecHook from context's public re-export.
  • Spurious # type: ignore[assignment] (cuprum/logging_hooks.py:43-44)
    — fields are typed HookRegistration | None, so assigning None should not
    need the ignore. Verify and remove (or narrow with a specific reason).
  • Dead FD aliases (cuprum/_pipeline_streams.py:103-110) —
    _extract_reader_fd / _extract_writer_fd are pure pass-throughs to
    _extract_stream_fd. Inline at the two call sites and delete.
  • Lazy in-function imports / import cycle — the pipeline modules use
    in-function imports and a _sh_module() sys.modules service-locator
    (cuprum/_pipeline_internals.py:40-45; also _pipeline_config.py:49,
    _pipeline_stage_streams.py:62,84, _process_lifecycle.py:140,187-188) to
    dodge a real cycle. Relocate the shared dataclasses (_StageObservation,
    _EventDetails, result types) into a dependency-free leaf module so these
    become normal top-level imports, and delete the _pipeline_spawn.py re-export
    shim.
  • en-GB spellingcuprum/adapters/logging_adapter.py:96
    "Programme" -> "Program"; align mixed serialise / serializable prose to
    en-GB-oxendict (identifiers may stay ecosystem-standard).

Verification

  • make check-fmt lint test green; make markdownlint for any doc touched.

References

  • Cuprum refactoring audit — consistency / dead-code / smaller items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions