pytorch/caffe2/python
Sergii Dymchenko f51f6aa387 Fix non-existing parameters in docstrings (#90505)
Continuation after https://github.com/pytorch/pytorch/pull/90163.

Here is a script I used to find all the non-existing arguments in the docstrings (the script can give false positives in presence of *args/**kwargs or decorators):

_Edit:_
I've realized that the indentation is wrong for the last `break` in the script, so the script only gives output for a function if the first docstring argument is wrong. I'll create a separate PR if I find more issues with corrected script.

``` python
import ast
import os
import docstring_parser

for root, dirs, files in os.walk('.'):
    for name in files:
        if root.startswith("./.git/") or root.startswith("./third_party/"):
            continue
        if name.endswith(".py"):
            full_name = os.path.join(root, name)
            with open(full_name, "r") as source:
                tree = ast.parse(source.read())
                for node in ast.walk(tree):
                    if isinstance(node, ast.FunctionDef):
                        all_node_args = node.args.args
                        if node.args.vararg is not None:
                            all_node_args.append(node.args.vararg)
                        if node.args.kwarg is not None:
                            all_node_args.append(node.args.kwarg)
                        if node.args.posonlyargs is not None:
                            all_node_args.extend(node.args.posonlyargs)
                        if node.args.kwonlyargs is not None:
                            all_node_args.extend(node.args.kwonlyargs)
                        args = [a.arg for a in all_node_args]
                        docstring = docstring_parser.parse(ast.get_docstring(node))
                        doc_args = [a.arg_name for a in docstring.params]
                        clean_doc_args = []
                        for a in doc_args:
                            clean_a = ""
                            for c in a.split()[0]:
                                if c.isalnum() or c == '_':
                                    clean_a += c
                            if clean_a:
                                clean_doc_args.append(clean_a)
                        doc_args = clean_doc_args
                        for a in doc_args:
                            if a not in args:
                                print(full_name, node.lineno, args, doc_args)
                            break

```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/90505
Approved by: https://github.com/malfet, https://github.com/ZainRizvi
2022-12-09 21:43:09 +00:00
..
benchmarks
docs
examples
fakelowp
helpers
ideep
layers
mint
mkl
modeling
models Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
onnx Fix typos under caffe2 directory (#87840) 2022-10-28 04:53:36 +00:00
operator_test Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
predictor
rnn
serialized_test
test
trt Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
__init__.py
_import_c_extension.py
_import_c_extension.pyi
allcompare_test.py
attention.py
benchmark_generator.py
binarysize.py
brew.py
brew_test.py
build.py
cached_reader.py
caffe_translator.py Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
caffe_translator_test.py
checkpoint.py
checkpoint_test.py
clean_workspace_test.py extract out the clean workspace test to its own file (#88682) 2022-11-09 13:48:57 +00:00
CMakeLists.txt Move workspace related functions to separate file (#87651) 2022-10-29 04:52:01 +00:00
cnn.py
context.py
context.pyi
context_test.py
control.py
control_ops_grad.py
control_ops_grad_test.py
control_ops_util.py
control_test.py
convert.py
convert_test.py
convnet_benchmarks.py
convnet_benchmarks_test.py
core.py Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
core_gradients_test.py
core_test.py
crf.py
crf_predict.py
crf_viterbi_test.py
data_parallel_model.py
data_parallel_model_test.py
data_workers.py
data_workers_test.py
dataio.py Fix non-existing parameters in docstrings (#90505) 2022-12-09 21:43:09 +00:00
dataio_test.py
dataset.py
db_file_reader.py
db_test.py
device_checker.py
dlpack.h Revert "Add DLPack support for XPU backend by mapping to kDLOneAPI in DLPack (#82867)" 2022-08-07 20:38:29 +00:00
dyndep.py
embedding_generation_benchmark.py
experiment_util.py
extension_loader.py
fakefp16_transform_lib.py
filler_test.py
functional.py
functional_test.py
fused_8bit_rowwise_conversion_ops_test.py
gradient_check_test.py
gradient_checker.py
gru_cell.py
hip_test_util.py
hsm_util.py
hypothesis_test.py
hypothesis_test_util.py
ideep_test_util.py
layer_model_helper.py
layer_model_instantiator.py
layer_parameter_sharing_test.py
layer_test_util.py
layers_test.py
lazy.py
lazy_dyndep.py
lazy_dyndep_test.py
lengths_reducer_fused_8bit_rowwise_ops_test.py
lengths_reducer_rowwise_8bit_ops_test.py
lstm_benchmark.py
memonger.py
memonger_test.py
mkl_test_util.py
model_device_test.py
model_helper.py Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
model_helper_test.py
modifier_context.py
mpi_python.cc
muji.py
muji_test.py
net_builder.py
net_builder_test.py
net_drawer.py
net_printer.py
net_printer_test.py
nomnigraph.py
nomnigraph_test.py
nomnigraph_transformations.py
nomnigraph_transformations_test.py
normalizer.py
normalizer_context.py
normalizer_test.py
numa_benchmark.py
numa_test.py
observer_test.py
operator_fp_exceptions_test.py
optimizer.py [LRD] Allowing using dedicated iteration counter for learning rate (#85195) 2022-09-27 00:56:57 +00:00
optimizer_context.py
optimizer_test.py [LRD] Allowing using dedicated iteration counter for learning rate (#85195) 2022-09-27 00:56:57 +00:00
optimizer_test_util.py
parallel_workers.py
parallel_workers_test.py
parallelize_bmuf_distributed_test.py
pipeline.py
pipeline_test.py
predictor_constants.py
pybind_state.cc Fix: prefer .is_none() over .is(py::none()) for pybind11 in caffe2 (#88199) 2022-11-17 05:01:11 +00:00
pybind_state.h
pybind_state_dlpack.cc
pybind_state_dlpack.h
pybind_state_gpu.cc
pybind_state_hip.cc
pybind_state_ideep.cc
pybind_state_int8.cc
pybind_state_nomni.cc
pybind_state_registry.cc
pybind_state_registry.h
pybind_workspace.cc Move workspace related functions to separate file (#87651) 2022-10-29 04:52:01 +00:00
pybind_workspace.h Move workspace related functions to separate file (#87651) 2022-10-29 04:52:01 +00:00
python_op_test.py
queue_util.py
record_queue.py
recurrent.py docs: Fix a few typos (#81435) 2022-07-14 04:20:26 +00:00
regularizer.py
regularizer_context.py
regularizer_test.py
rnn_cell.py
schema.py Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
schema_test.py
scope.py
scope_test.py
session.py
session_test.py
sparse_to_dense_mask_test.py
sparse_to_dense_test.py
task.py
task_test.py
test_util.py
text_file_reader.py
timeout_guard.py
toy_regression_test.py
transformations.py
transformations_test.py
tt_core.py
tt_core_test.py
utils.py [LRD] Allowing using dedicated iteration counter for learning rate (#85195) 2022-09-27 00:56:57 +00:00
utils_test.py
visualize.py
workspace.py
workspace_test.py extract out the clean workspace test to its own file (#88682) 2022-11-09 13:48:57 +00:00