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

[*.py] Rename "Arguments:" to "Args:" #323

Conversation

SamuelMarks
Copy link

I've written custom parsers and emitters for everything from docstrings to classes and functions. However, I recently came across an issue with the TensorFlow codebase: inconsistent use of Args: and Arguments: in its docstrings. It is easy enough to extend my parsers to support both variants, however it looks like Arguments: is wrong anyway, as per:

Therefore, only Args: is valid. This PR replaces them throughout the codebase.

PS: For related PRs, see tensorflow/tensorflow/pull/45420

@@ -19,7 +19,7 @@ def __init__(self, project_url=None):

def process_docstring(self, docstring):
docstring = docstring.replace("Args:", "# Arguments")
docstring = docstring.replace("Arguments:", "# Arguments")
docstring = docstring.replace("Args:", "# Arguments")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, only accept the change on this line if keras-team/keras-contrib#550 is accepted (oh, and change to docstring.replace("Args:", "# Args"))

@fchollet
Copy link
Contributor

fchollet commented Dec 6, 2020

As a general convention, use fully-spelled out names rather than abbreviations, since it is more user-friendly. "Args" is not a dictionary word. We could simply standardize on "Arguments".

@SamuelMarks
Copy link
Author

SamuelMarks commented Dec 6, 2020

@fchollet As a general convention following the formal specification is recommended; to take your advice to its logical extreme, using function_definition rather than def in Python code would be warranted! In this circumstance though, there is no formal specification, however the references shown from Google indicates official use of Args:—rather than Arguments:—and sphinx is following suite.

Although args is not an English word, it is used throughout the Python codebase, e.g., ast.FunctionDef. Also arg is [sometimes] a dictionary word (Merriam Webster, wiktionary).

Standardising is a good idea. You can get Google to change their style guide to accept Arguments: as valid, or [as I'd recommend] you can accept this PR.

(keras-io#a21a7f8)$ for name in 'Args:' 'Arguments:'; do
     printf '%-10s %04d\n' "$name" "$(rg -IFtpy --count-matches "$name" | paste -s -d+ -- | bc)"; done
Args:      0008
Arguments: 0015

@fchollet fchollet closed this Jun 9, 2021
@SamuelMarks
Copy link
Author

@fchollet Did you see my comment? - Happy to merge master and redo sed (or fastmod -F)…

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