Skip to content

Add docstrings to tracer.py and several utils functions#2687

Open
mastash3ff wants to merge 1 commit intosimonw:mainfrom
mastash3ff:docs/add-docstrings-tracer-utils
Open

Add docstrings to tracer.py and several utils functions#2687
mastash3ff wants to merge 1 commit intosimonw:mainfrom
mastash3ff:docs/add-docstrings-tracer-utils

Conversation

@mastash3ff
Copy link
Copy Markdown

@mastash3ff mastash3ff commented Apr 5, 2026

Summary

This PR adds Python docstrings to a handful of public functions and classes that were previously undocumented. No logic, behaviour, or tests are changed.

datasette/tracer.py

  • get_task_id — explains the context-variable fallback and why child tasks share the parent's ID
  • trace_child_tasks — describes how it pins the parent task ID for child task attribution
  • trace — documents the no-op path, the yielded dict, and the reserved-key constraint
  • capture_traces — documents the list argument and de-registration on exit
  • AsgiTracer class — describes the ?_trace=1 injection behaviour and the body-size guard

datasette/utils/__init__.py

  • get_outbound_foreign_keys — notes the compound-key exclusion
  • get_all_foreign_keys — shows the returned dict shape and sort guarantee
  • detect_spatialite — explains the geometry_columns heuristic
  • filters_should_redirect — documents the legacy-to-compact parameter conversion and the None-value sentinel
  • format_bytes — describes the unit-step logic
  • escape_fts — clarifies the quoting strategy and the unbalanced-quote fix

Test plan

  • ruff check datasette/tracer.py datasette/utils/__init__.py passes (verified locally)
  • Existing test suite passes unchanged (docstring-only diff)

📚 Documentation preview 📚: https://datasette--2687.org.readthedocs.build/en/2687/

Document get_task_id, trace_child_tasks, trace, capture_traces, and
AsgiTracer in tracer.py, and get_outbound_foreign_keys,
get_all_foreign_keys, detect_spatialite, filters_should_redirect,
format_bytes, and escape_fts in utils/__init__.py.  No logic changes.
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.

1 participant