Skip to content

[CLIENT-4425] Docs: fix broken cross references for type aliases#991

Open
juliannguyen4 wants to merge 173 commits intodevfrom
CLIENT-4425-docs-fix-broken-internal-references
Open

[CLIENT-4425] Docs: fix broken cross references for type aliases#991
juliannguyen4 wants to merge 173 commits intodevfrom
CLIENT-4425-docs-fix-broken-internal-references

Conversation

@juliannguyen4
Copy link
Copy Markdown
Collaborator

@juliannguyen4 juliannguyen4 commented Mar 16, 2026

  • Moving to sphinx-autodoc-typehints extension which handles the type aliases better than the default autodoc that comes with sphinx. Using the latter causes the type aliases to not evaluate properly in nitpicky mode and raises errors. Also fixes error when using list[TypeKey] as a type hint in a function signature.

Drawbacks of using sphinx-autodoc-typehints

More compute energy and time is spent to inject the type hints into the docstrings

Extra Changes

  • Docs: replace the type aliases in the type hints with the actual types. This should be fine for the most part; only a few places like _BaseExpr.compile() have long return types, but that's more of an internal implementation detail IMO
  • Replace some of the old classes from typing module with native types. The old classes were used because the native types didn't support subscripting (e.g list, dict) until Python 3.9+
  • Remove some of the duplicate type hints from docstrings in aerospike_helpers. sphinx-autodoc-typehints generates the type hints in the docstrings using the signatures.
  • Remove some double quotes from type hints where not needed. I don't believe they are forward references since the type aliases are defined at the top of the files.

TODO

  • Replace outdated / deprecated typing classes with native ones. Check for option to trigger warning/err in ci/cd probably through mypy Will make a separate jira ticket
  • sphinx-autodoc-typehints additional dependency requires Python 3.12+ Shouldn't be a problem as long as the docs are compiled on readthedocs.org

Known issues introduced here

  • _cdt_ctx return value formatting is duplicated in cdt_ctx.py docs fixed
  • Methods with variable args lost their type hints

Out of scope

  • CLIENT-4613 Remove all double quotes from type hints in aerospike_helpers

Manual testing

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.86%. Comparing base (1f81f80) to head (44319bd).
⚠️ Report is 12 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #991      +/-   ##
==========================================
- Coverage   83.87%   83.86%   -0.02%     
==========================================
  Files          99       99              
  Lines       14514    14490      -24     
==========================================
- Hits        12174    12152      -22     
+ Misses       2340     2338       -2     

☔ View full report in Codecov by Sentry.
📢 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.

…t documented _cdt_ctx (or private classes in general). TODO: add this error to ignore list
…name to work, we need to add back these lines.
…ing, just make them public for now. Trying to see if the doc's cross references now work for the other errors
…xpression isn't actually defined anywhere except in .rst
…ed as None to the user, otherwise maybe this should just be annotated as tuple
…es, and the latter is missing the type hint in the docs. So try unquoting to see if it shows up in docs preview. TODO - if it does then I should report this as an issue in repo
@juliannguyen4 juliannguyen4 force-pushed the CLIENT-4425-docs-fix-broken-internal-references branch from eda1a2b to aec5004 Compare April 13, 2026 17:15
juliannguyen4 added a commit that referenced this pull request Apr 13, 2026
…liases) (#1024)

Add type aliases in aerospike_helpers to ignore list for now. There is another PR #991 that fixes the warnings for those type aliases, but it leverages a new extension called sphinx-autodoc-typehints which currently causes some regressions in how the docs are rendered.
…roken-internal-references

# Conflicts:
#	aerospike_helpers/batch/records.py
#	aerospike_helpers/cdt_ctx.py
#	aerospike_helpers/expressions/arithmetic.py
#	aerospike_helpers/expressions/resources.py
#	doc/aerospike_helpers.expressions.rst
#	doc/client.rst
#	doc/conf.py
#	doc/query.rst
#	doc/transaction.rst
@juliannguyen4 juliannguyen4 changed the title [CLIENT-4425] Docs: fix broken cross references in API documentation [CLIENT-4425] Docs: fix broken cross references for type aliases Apr 13, 2026
…e type hints from the docstrings and adding them to the signatures so that the extension can insert the type hints in the docstrings. TODO there is a lot so just use AI
… TODO using a formatter would be easier i.e black
…and 2) remove the duplicate type hints in the docstrings after they are already in the signature
…docstring if it only documents the type being returned.
…xpanded, since it's not defined in cdt_ctx.py
… to be expanded, since it's not defined in cdt_ctx.py"

This reverts commit 0d7d81e.
…dt_ctx.py. (although not sure where cdt_ctx.py is being imported from)
…they are not evaluated at runtime. They are only used for type checking
…y we don't need to import Union, and this will hopefully fix the sphinx nitpicky errors around Union not being available at runtime"
…cstrings type hints should be documented in the classes
…_reference errors related to it. It also reduces repetition
…ne module. TODO - just use cursor from now on
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.

3 participants