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 #4374: Add docstrings to Python files. #6013

Merged
merged 4 commits into from
Dec 25, 2018

Conversation

vibhor98
Copy link
Contributor

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 scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR follows the style guide.
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • 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.

@vibhor98 vibhor98 requested a review from nithusha21 December 20, 2018 10:13
Copy link
Contributor

@nithusha21 nithusha21 left a comment

Choose a reason for hiding this comment

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

Hi @vibhor98 thanks for the PR! Here is my first pass. One overall comment, just confirming. Docstrings in the _test files don't need args/return right?

core/domain/feedback_jobs_continuous_test.py Outdated Show resolved Hide resolved
core/domain/feedback_jobs_continuous_test.py Outdated Show resolved Hide resolved
core/domain/feedback_jobs_continuous_test.py Outdated Show resolved Hide resolved
core/domain/feedback_jobs_continuous_test.py Outdated Show resolved Hide resolved
core/domain/learner_playlist_services_test.py Outdated Show resolved Hide resolved
core/domain/user_jobs_one_off_test.py Outdated Show resolved Hide resolved
core/domain/user_services_test.py Outdated Show resolved Hide resolved
@@ -998,6 +1003,7 @@ def utcnow(cls):


class LastExplorationEditedIntegrationTests(test_utils.GenericTestBase):
"""Integration tests for the exploration that is edited at the last."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure this is right. Could you confirm? I have to look through the code. Will check and let you know in the next review pass.

Copy link
Contributor

@nithusha21 nithusha21 Dec 25, 2018

Choose a reason for hiding this comment

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

Suggested change
"""Integration tests for the exploration that is edited at the last."""
"""Integration tests for testing the time the user last edited an exploration updates correctly."""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -1069,6 +1075,7 @@ def test_last_exp_edit_time_gets_updated(self):


class LastExplorationCreatedIntegrationTests(test_utils.GenericTestBase):
"""Integration tests for the exploration that is created at the last."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Integration tests for the exploration that is created at the last."""
"""Integration tests for the time the user last created an exploration updates correctly."""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

core/jobs_test.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Dec 20, 2018

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6013   +/-   ##
=======================================
  Coverage     45.3%   45.3%           
=======================================
  Files          520     520           
  Lines        30667   30667           
  Branches      4597    4597           
=======================================
  Hits         13893   13893           
  Misses       16774   16774

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d101331...9926966. Read the comment docs.

@nithusha21
Copy link
Contributor

Hi @vibhor98 please note the lint check failures.

@vibhor98
Copy link
Contributor Author

Hi @nithusha21, I've resolved lint errors. Please review once again! Thanks!

Copy link
Contributor

@bansalnitish bansalnitish left a comment

Choose a reason for hiding this comment

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

Hi @vibhor98, I left some comments for you, PTAL!

@@ -57,6 +57,9 @@ def assign_rating_to_exploration(user_id, exploration_id, new_rating):
raise Exception('Invalid exploration id %s' % exploration_id)

def _update_user_rating():
"""Updates the user rating of the exploration. Returns the old rating
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a single sentence would be better without a break, what do you say? and returns the old rating....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @bansalnitish, I did exactly the same as in your both the comments. But after @nithusha21's review, I made these changes. I think both the ways are acceptable but it's just the matter of individual preferences.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, sounds good!

Copy link
Contributor

Choose a reason for hiding this comment

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

Typically, we would have a "returns" part of the docstring, I wanted to have it somewhat resemble that. That's why the split sentences. But yeah, I think this does come down to personal preference :P

event_services.StartExplorationEventHandler.record(
exp_id, exp_version, state_name, session_id, {},
feconf.PLAY_TYPE_NORMAL)

def _get_calc_output_model(
self, exploration_id, state_name, calculation_id,
exploration_version=stats_jobs_continuous.VERSION_ALL):
"""Gets the StateAnswersCalcOutputModel corresponding to the given
Copy link
Contributor

Choose a reason for hiding this comment

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

Gets -> Returns ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto as above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gets is fine I believe, and consistent with the function name. That's why I suggested gets :)

Copy link
Contributor

@nithusha21 nithusha21 left a comment

Choose a reason for hiding this comment

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

Overall looks good. There are a couple of places I have to get back to you about. Will do so soon.

@@ -106,6 +112,9 @@ def _get_all_completed_collection_ids(self, user_id):
completed_activities_model else [])

def _get_all_incomplete_exp_ids(self, user_id):
"""Returns the list of all the incomplete exploration ids of the learner
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem done?

@@ -57,6 +57,9 @@ def assign_rating_to_exploration(user_id, exploration_id, new_rating):
raise Exception('Invalid exploration id %s' % exploration_id)

def _update_user_rating():
"""Updates the user rating of the exploration. Returns the old rating
Copy link
Contributor

Choose a reason for hiding this comment

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

Typically, we would have a "returns" part of the docstring, I wanted to have it somewhat resemble that. That's why the split sentences. But yeah, I think this does come down to personal preference :P

event_services.StartExplorationEventHandler.record(
exp_id, exp_version, state_name, session_id, {},
feconf.PLAY_TYPE_NORMAL)

def _get_calc_output_model(
self, exploration_id, state_name, calculation_id,
exploration_version=stats_jobs_continuous.VERSION_ALL):
"""Gets the StateAnswersCalcOutputModel corresponding to the given
Copy link
Contributor

Choose a reason for hiding this comment

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

Gets is fine I believe, and consistent with the function name. That's why I suggested gets :)

@@ -924,6 +924,7 @@ def test_invalid_subject_interests_are_not_accepted(self):


class LastLoginIntegrationTests(test_utils.GenericTestBase):
"""Integration tests for last login by the user."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, see lines 64-67 in user_services.py. The lastLogin corresponds to the time the user last logged in. So maybe,

Suggested change
"""Integration tests for last login by the user."""
"""Integration tests for testing that the last login time for a user updates correctly."""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@nithusha21 nithusha21 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!

@nithusha21 nithusha21 merged commit 92c4ecf into oppia:develop Dec 25, 2018
@vibhor98 vibhor98 deleted the add-dstrings branch December 25, 2018 19:00
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