-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Small fixes for utils/check_docstrings.py #38915
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
base: main
Are you sure you want to change the base?
Conversation
5f6f622
to
b51c9d5
Compare
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…d use `ast.Constant` More verbose exceptions in `fix_docstring` on docstring formatting issues.
b51c9d5
to
42669f6
Compare
Hi @manueldeprada Thanks a lot! This part is old and I am not the author. I think it makes sense but just have one question. Looks like our current code is passing this modified check. |
@@ -947,7 +948,17 @@ def fix_docstring(obj: Any, old_doc_args: str, new_doc_args: str): | |||
|
|||
if "".join(source[start_idx:idx])[:-1] != old_doc_args: | |||
# Args are not fully defined in the docstring of this object | |||
return | |||
obj_file = find_source_file(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logically it looks good. But I have a bit hard time to understand why we might have this situation.
In match_docstring_with_signature
, we have
old_doc_arg = "\n".join(obj_doc_lines[start_idx:idx])
and here old_doc_args
is the original content of obj.
If you happen to know why we might have this situation "".join(source[start_idx:idx])[:-1] != old_doc_args
(and even better if you have an example) , that would be very nice 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's not because of you PR confusing me, the block is already there , just return silently.
node.n
bynode.value
(deprecation notice)ast.Num
byast.Constant
(deprecation notice)--fix_and_overwrite
is passed but fixing fails, exit with a detailed exception instead of failing silently.