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

Fix part of #7427: Adds args, returns and raises in docstrings of utils.py #8134

Merged
merged 9 commits into from
Dec 13, 2019

Conversation

Arnesh07
Copy link
Contributor

@Arnesh07 Arnesh07 commented Dec 5, 2019

Explanation

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python -m scripts.pre_commit_linter and python -m scripts.run_frontend_tests.
  • The PR is made from a branch that's not called "develop".
  • The PR has an appropriate "PROJECT: ..." label (Please add this label for the first-pass review of the PR).
  • The PR has an appropriate "CHANGELOG: ..." label (If you are unsure of which label to add, ask the reviewers for guidance).
  • The PR follows the style guide.
  • The PR addresses the points mentioned in the codeowner checks for the files/folders changed. (See the codeowner's wiki page.)
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer and don't tick this checkbox.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue. Do not only request the review but also add the reviewer as an assignee.

@Arnesh07 Arnesh07 requested a review from aks681 as a code owner December 5, 2019 19:31
@oppiabot
Copy link

oppiabot bot commented Dec 5, 2019

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!

@Showtim3
Copy link
Contributor

Showtim3 commented Dec 5, 2019

@Arnesh07 Don't fill the checkboxes that are not valid. @aks681 PTAL!
Thanks

Copy link
Contributor

@aks681 aks681 left a 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.

@aks681 aks681 assigned Arnesh07 and aks681 and unassigned aks681 Dec 5, 2019
@codecov
Copy link

codecov bot commented Dec 5, 2019

Codecov Report

Merging #8134 into develop will not change coverage.
The diff coverage is n/a.

@@           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
Flag Coverage Δ
#backend 100% <ø> (ø) ⬆️
#frontend 48.37% <ø> (ø) ⬆️
Impacted Files Coverage Δ
utils.py 100% <ø> (ø) ⬆️

@Arnesh07
Copy link
Contributor Author

Arnesh07 commented Dec 8, 2019

@aks681 I have made the changes, PTAL.

Copy link
Contributor

@aks681 aks681 left a 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.
Copy link
Contributor

@aks681 aks681 Dec 11, 2019

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
Copy link
Contributor

Choose a reason for hiding this comment

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

constants.DEV_MODE

@Arnesh07
Copy link
Contributor Author

I have made the changes, PTAL. @aks681

Copy link
Contributor

@aks681 aks681 left a 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.

@Arnesh07
Copy link
Contributor Author

@kevinlee12 Who would be merging this PR?

@kevinlee12 kevinlee12 merged commit f773c08 into oppia:develop Dec 13, 2019
@kevinlee12
Copy link
Contributor

I went ahead and merged it!

@Arnesh07
Copy link
Contributor Author

I went ahead and merged it!

Thank you!

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.

4 participants