-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
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.
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/user_services_test.py
Outdated
@@ -998,6 +1003,7 @@ def utcnow(cls): | |||
|
|||
|
|||
class LastExplorationEditedIntegrationTests(test_utils.GenericTestBase): | |||
"""Integration tests for the exploration that is edited at the last.""" |
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.
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.
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.
"""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.""" |
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.
Done
core/domain/user_services_test.py
Outdated
@@ -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.""" |
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
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.
"""Integration tests for the exploration that is created at the last.""" | |
"""Integration tests for the time the user last created an exploration updates correctly.""" |
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.
Done
Codecov Report
@@ 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.
|
Hi @vibhor98 please note the lint check failures. |
Hi @nithusha21, I've resolved lint errors. Please review once again! 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.
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 |
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.
I think a single sentence would be better without a break, what do you say? and returns the old rating....
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.
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.
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.
Okay, sounds good!
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.
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 |
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.
Gets -> Returns ?
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 as above.
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.
Gets is fine I believe, and consistent with the function name. That's why I suggested gets :)
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.
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 |
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 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 |
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.
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 |
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.
Gets is fine I believe, and consistent with the function name. That's why I suggested gets :)
core/domain/user_services_test.py
Outdated
@@ -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.""" |
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.
Ah, see lines 64-67 in user_services.py. The lastLogin corresponds to the time the user last logged in. So maybe,
"""Integration tests for last login by the user.""" | |
"""Integration tests for testing that the last login time for a user updates correctly.""" |
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.
Done
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!
Explanation
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.