Skip to content

Refactor _wrap_callback timeout and body handling with match #3110

@adamtheturtle

Description

@adamtheturtle

Summary

Refactor _wrap_callback’s inner function in decorators.py to use match for timeout normalization and request body → bytes conversion.

Precise location

  • File: src/mock_vws/_requests_mock_server/decorators.py
  • Method: MockVWS._wrap_callback → nested wrapped
  • Lines: approximately 170–186

Branch 1: timeout from req_kwargs

  • isinstance(timeout, tuple) → use read component timeout[1]
  • Then isinstance(timeout, (int, float))effective = float(timeout)

Candidate: match timeout: with case tuple():, case int() | float():, case _: effective = None (preserve current semantics).

Branch 2: request.body

  • Noneb""
  • isinstance(raw_body, str) → UTF-8 encode
  • Else → treat as bytes

Candidate: match raw_body: with case None:, case str():, case _: (bytes).

Acceptance criteria

  • Delay / timeout / requests.exceptions.Timeout behavior unchanged.
  • Existing tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions