Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apidoc/python: Fix xrefs to type parameters #372

Merged
merged 1 commit into from
Jul 23, 2024
Merged

Conversation

jbms
Copy link
Owner

@jbms jbms commented Jul 23, 2024

Previously, if a function introduced a type parameter, any references to that type parameter in the signature itself were correctly resolved. However, when documenting function parameters, the type from the signature is duplicated next to the parameter name, and any references to type parameters in these duplicated types were not correctly resolved.

This commit fixes that issue by applying the same resolution logic to the duplicated types.

@jbms jbms requested a review from 2bndy5 July 23, 2024 06:26
@2bndy5
Copy link
Collaborator

2bndy5 commented Jul 23, 2024

Not sure how you discovered this. It might be worth adding :param: fields to the demo API docs in

@overload
def get(self, key: K) -> Optional[V]: ...
@overload
def get(self, key: K, default: V) -> V: ...
@overload
def get(self, key: K, default: T) -> Union[V, T]: ...
def get(self, key: K, default=None):
"""Return the mapped value, or the specified default."""

@jbms
Copy link
Owner Author

jbms commented Jul 23, 2024

Not sure how you discovered this. It might be worth adding :param: fields to the demo API docs in

Done.

Without this fix, the T in default :T as shown separately for the function parameter leads to an ambiguous reference warning if there is more than T anywhere, because it gets resolved as a top-down T reference.

Previously, if a function introduced a type parameter, any references to
that type parameter in the signature itself were correctly resolved.
However, when documenting function parameters, the type from the
signature is duplicated next to the parameter name, and any references
to type parameters in these duplicated types were not correctly
resolved.

This commit fixes that issue by applying the same resolution logic to
the duplicated types.
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.22%. Comparing base (7e2d559) to head (0d4de7e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #372      +/-   ##
==========================================
+ Coverage   63.00%   67.22%   +4.21%     
==========================================
  Files          68       68              
  Lines        8502     8512      +10     
==========================================
+ Hits         5357     5722     +365     
+ Misses       3145     2790     -355     

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

@jbms jbms merged commit 162f262 into main Jul 23, 2024
62 checks passed
@jbms jbms deleted the fix-type-param-refs branch July 23, 2024 18:31
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