-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix part of #7427: Adds args, returns and raises in docstrings of utils.py #8134
Conversation
Hi, @Arnesh07. This pull request does not have a "CHANGELOG: ..." label as mentioned in the PR checkbox list. Please add this label. PRs without this label will not be merged. If you are unsure of which label to add, please ask the reviewers for guidance. Thanks! |
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.
The main docstrings look fine. Just a couple of distinct comments repeated throughout. PTAL! :)
utils.py
Outdated
filepath: str. A full path to the file. | ||
|
||
Returns: | ||
*. Data url created from the filepath of the PNG. |
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.
Why is this *
? Doesn't this return a string? If so, mention it as str
here.
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.
This function returns a call to the function convert_png_binary_to_data_url
which has its return type specified like this. Can you make sure whether it is a string so that I can modify docstrings of both the functions? @aks681
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.
@aks681 ?
utils.py
Outdated
@@ -398,20 +405,30 @@ def get_time_in_millisecs(datetime_obj): | |||
datetime_obj: datetime. An object of type datetime.datetime. | |||
|
|||
Returns: | |||
float. This returns the time in the millisecond since the Epoch. | |||
float. This returns the time in the milliseconds since the Epoch. |
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.
Drop the 'the' before milliseconds.
Can you edit this comment as well to explain the returned variable? See the below comment regarding it.
utils.py
Outdated
"""Returns time in milliseconds since the Epoch. | ||
|
||
Returns: | ||
float. This returns the time in the milliseconds since the Epoch. |
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.
Ditto.
Also, here you should explain the returned variable itself. So, the comment should be something like 'The time in milliseconds since the Epoch'.
utils.py
Outdated
time_msec: float. Time in milliseconds since the Epoch. | ||
|
||
Returns: | ||
str. Returns a string representing the time. |
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.
Ditto here. No need to have 'Returns a', since you need to be explaining the returned variable itself here.
utils.py
Outdated
earlier_datetime: datetime. The earlier datetime. | ||
|
||
Returns: | ||
bool. Returns true if difference between two datetimes is less than |
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.
Ditto, no need of 'Returns' in this line.
utils.py
Outdated
|
||
Args: | ||
base_path: str. The initial path upon which components would be added. | ||
path_components: *. Components that would be added to the path. |
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.
Whys is this '*'? If it is a list (which seems to be the case), mention that as list(datatype)
where datatype is the type of the values in list.
utils.py
Outdated
path_components: *. Components that would be added to the path. | ||
|
||
Returns: | ||
str. Returns the path that is obtained after adding the components. |
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.
Ditto, drop returns and explain the value itself.
utils.py
Outdated
path: str. Path that is to be normalized. | ||
|
||
Returns: | ||
str. Returns path if it is not null else returns a dot string. |
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.
Ditto here and elsewhere.
utils.py
Outdated
@@ -498,6 +538,14 @@ def require_valid_name(name, name_type, allow_empty=False): | |||
name_type: str. A human-readable string, like 'the exploration title' or | |||
'a state name'. This will be shown in error messages. | |||
allow_empty: bool. If True, empty strings are allowed. | |||
|
|||
Raises: | |||
Exception: Raised when name isn't a string. |
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.
Again, no need to have 'Raises' in all these definitions, since the heading is 'Raises'. Just have the exception message itself here and elsewhere.
Codecov Report
@@ Coverage Diff @@
## develop #8134 +/- ##
========================================
Coverage 70.81% 70.81%
========================================
Files 1073 1073
Lines 63020 63020
Branches 4880 4880
========================================
Hits 44627 44627
Misses 16949 16949
Partials 1444 1444
|
@aks681 I have made the changes, PTAL. |
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.
Almost there! Just 2 more comments.
utils.py
Outdated
"""Returns time in milliseconds since the Epoch. | ||
|
||
Returns: | ||
float. The time in the milliseconds since the Epoch. |
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.
Drop the the
before milliseconds.
utils.py
Outdated
return python_utils.urllib_unquote(escaped_string).decode('utf-8') | ||
|
||
|
||
def get_asset_dir_prefix(): | ||
"""Returns prefix for asset directory depending whether dev or prod. | ||
It is used as a prefix in urls for images, css and script files. | ||
|
||
Returns: | ||
str. Prefix '/build' if constants,DEV_MODE is false, otherwise |
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.
constants.DEV_MODE
I have made the changes, PTAL. @aks681 |
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.
LGTM! Thanks!
Also, as a side note, make sure to address every review comment individually so that we know each of them were addressed.
@kevinlee12 Who would be merging this PR? |
I went ahead and merged it! |
Thank you! |
Explanation
Checklist
python -m scripts.pre_commit_linter
andpython -m scripts.run_frontend_tests
.