docs: fix documented parameter names that do not match the signature - #4156
Open
massimiliano1991 wants to merge 1 commit into
Open
docs: fix documented parameter names that do not match the signature#4156massimiliano1991 wants to merge 1 commit into
massimiliano1991 wants to merge 1 commit into
Conversation
Three docstrings document a parameter name that does not exist in the function signature: - recursively_apply: documents `main_type`, the parameter is `test_type` - SwanLabTracker.log: documents `data`, the parameter is `values` - MLflowTracker.log_figure: documents `**kwargs`, the parameter is `**save_kwargs` For the first two the mismatch is not just cosmetic: both functions accept `**kwargs`, so a keyword taken from the docs is silently swallowed and forwarded. `recursively_apply(func, data, main_type=X)` raises "<user function>() got an unexpected keyword argument 'main_type'" - an error that names the caller's own function, not the one with the wrong docs. Docs only, no behaviour change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Three docstrings document a parameter name that does not exist in the function signature:
utils/operations.pyrecursively_applymain_typetest_typetracking.pySwanLabTracker.logdatavaluestracking.pyMLflowTracker.log_figure**kwargs**save_kwargsWhy it's worth fixing
For the first two the mismatch is not only cosmetic. Both functions accept
**kwargs, so akeyword copied from the documentation is not rejected at the boundary — it is swallowed and
forwarded to the user's own callback:
The traceback names
my_fn, notrecursively_apply, so nothing points back to the docstringthat suggested the argument.
recursively_apply's docstring also describesmain_typeas a type defaulting totorch.Tensor, whiletest_typeis a predicate defaulting tois_torch_tensor. The threeother references to
main_typein the same docstring (including theReturns:line) areupdated to match.
For
MLflowTracker.log_figurethe**form absorbs any name, so there is no error — but thedocstring also pointed at
mlflow.log_imagerather thanmlflow.log_figure. The surroundingArgs:block had its description lines un-indented, which breaks rendering, so those lines arere-indented to the style used by the rest of the file.
SwanLabTracker.loghad the same issueand now matches the other trackers'
logmethods in that module.How these were found
Mechanically: parsing each
Args:block and diffing it against theastsignature, thenchecking each hit by hand. Only these three came out as documented-but-absent across
src/accelerate.Checks
ruff format --checkclean on both files;ruff checkreports only pre-existing findings inuntouched lines