Repository navigation
Conversation
|
Hi @Hirujan-R! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
stroxler
left a comment
There was a problem hiding this comment.
This looks pretty good to me, thanks!
It could use a rebase, because for technical reasons auto-import (which makes merging much easier) doesn't happen on a first PR before the CLA is signed; usually rebasing and pushing will trigger auto-import.
While we're at it, two suggestions for improvement to make this even better:
-
Support declarations without a type. extract_numpydoc_param_names requires a colon, so it ignores x, *args, and **kwargs followed by indented descriptions. The numpydoc guide explicitly permits omitted types—and recommends that form for varargs/kwargs. The new tests only cover typed declarations.
-
Preserve multi-paragraph descriptions. The blank-line branch commits and clears the current parameter. Consequently, a description containing first paragraph, a blank line, then an indented second paragraph silently loses the second paragraph. Keep the parameter active across blank lines and add a regression test.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Hover and signature help extract parameter documentation from docstrings, but only for Sphinx and Google styles. Parse numpydoc Parameters and Other Parameters sections so these docstrings also provide parameter documentation. The parser matches dashed section headers, handles multiple names per declaration, and stops when another section begins.
Numpydoc permits omitting parameter types, especially for *args and **kwargs, and descriptions may contain multiple paragraphs. Treat lines without a type as declarations and keep the current parameter active across blank lines so later paragraphs are preserved. Add regression tests for both cases.
474c6c3 to
abd6ab9
Compare
|
This pull request has been imported. If you are a Meta employee, you can view this in D128370293. (Because this pull request was imported automatically, there will not be any future comments.) |
|
@stroxler Thanks for the review! I addressed the feedback in
Tests:
Ready for another review. |
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
|
This pull request has been merged in 4e8e31a. |
Summary
Adds numpydoc parameter documentation to hover and signature help.
Pyrefly already extracts per-parameter documentation from Sphinx and
Google-style docstrings, but numpydoc
Parameterssections were ignored. As aresult, hovering a keyword argument or parameter documented in numpydoc showed
only its type. This adds a numpydoc parser alongside the existing style
parsers.
ParametersandOther Parameterssections using the dashedunderline form.
x, y : int),*args/**kwargs,defaults/colons in type annotations, and indented multi-line descriptions.
Returns.parse_parameter_documentationpath, so both hover andsignature help gain support without LSP-specific changes.
names. Existing Sphinx and Google behavior is unchanged.
This is limited to parameter documentation for hover/signature help; it does
not add special rendering for other numpydoc sections such as
ReturnsorRaises.Fixes #5313
Test Plan
cargo test -p pyrefly_python docstring— 50 passed.cargo test -p pyrefly parameter_doc— 10 passed, including the newnumpydoc hover test.
python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension— formatting and clippy passed.Added unit coverage for numpydoc parsing (multiple names, untyped declarations,
varargs/kwargs,
Other Parameters, section boundaries, indented docstrings,defaults, multi-paragraph descriptions, and empty descriptions) plus an LSP
hover test verifying that keyword arguments show numpydoc parameter
documentation.