Skip to content

docs(recipes): add type hints to request_id and custom media handler snippets#2665

Open
Aydeing wants to merge 2 commits into
falconry:masterfrom
Aydeing:docs/1820-type-hints-recipes
Open

docs(recipes): add type hints to request_id and custom media handler snippets#2665
Aydeing wants to merge 2 commits into
falconry:masterfrom
Aydeing:docs/1820-type-hints-recipes

Conversation

@Aydeing

@Aydeing Aydeing commented Jun 16, 2026

Copy link
Copy Markdown

Summary of Changes

Adds type annotations to a small, self-contained batch of recipe snippet files under examples/recipes/, as a step toward the rolling work in #1820:

  • examples/recipes/request_id_context.py
  • examples/recipes/request_id_log.py
  • examples/recipes/request_id_middleware.py
  • examples/recipes/request_id_structlog.py
  • examples/recipes/plain_text_main.py
  • examples/recipes/pretty_json_main.py

All changes are purely additive type annotations (plus an isort fix on two snippet imports that ruff check --fix produced). No runtime behavior changes; signatures only.

A docs/_newsfragments/1820.misc.rst towncrier entry is included.

Related Issues

Refs #1820

Pull Request Checklist

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. Reading our contribution guide at least once will save you a few review cycles!

If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable). (N/A — middleware snippets are framework-agnostic; the recipes are not split by interface.)
  • Added tests for changed code. (N/A — type-annotation-only changes to documentation snippets; no behavior to test.)
  • Performed automated tests and code quality checks by running tox. (Ran ruff format and ruff check on the touched files locally — All checks passed!. AST parse + runtime import smoke-checked on Python 3.13.)
  • Prefixed code comments with GitHub nick and an appropriate prefix. (No new non-trivial comments added.)
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules. (N/A — no new classes/functions/modules.)
    • Updated docstrings for any modifications to existing code. (N/A — signatures only.)
    • Updated both WSGI and ASGI docs (where applicable). (N/A.)
    • Added references to new classes, functions, or modules to the relevant RST file under docs/. (N/A.)
    • Updated all relevant supporting documentation files under docs/. (N/A — the recipe .rst files literalinclude these snippets unchanged.)
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization). (N/A — no new modules.)
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives. (N/A — annotations only.)
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst. (Added docs/_newsfragments/1820.misc.rst.)
  • LLM output, if any, has been carefully reviewed and tested by a human developer. (See also: Use of LLMs ("AI").) (Annotations were drafted with LLM assistance and then each signature was reviewed against the surrounding snippet semantics, formatted with ruff, and re-validated locally.)

Aydeing and others added 2 commits June 16, 2026 00:30
…examples

Annotate the recipe snippet files referenced from the docs so they
demonstrate the type-hinted style described in falconry#1820:

- examples/recipes/request_id_context.py
- examples/recipes/request_id_log.py
- examples/recipes/request_id_middleware.py
- examples/recipes/request_id_structlog.py
- examples/recipes/plain_text_main.py
- examples/recipes/pretty_json_main.py

No runtime behavior changes.

Refs: falconry#1820
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e18c27f) to head (e851179).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2665   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         7985      7985           
  Branches      1103      1103           
=========================================
  Hits          7985      7985           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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