Skip to content

Commit

Permalink
Fix part of oppia#8423: Added lint check to check for correctly forma…
Browse files Browse the repository at this point in the history
…ted typeinfo. (oppia#10107)

* temp

* Added check

* Fixed lint error

* Fixed lint errors

* Addressed review  comments

* Addressed review comments

* Added check for raises

* Fixed typo

* Addressed review comments

* Fixed backend tests

* Fixed lint errors

* Addressed review comments

* Fixed backend tests

* Addressed review comments

* Addressed review comments

* Fixed backend tests
  • Loading branch information
Hudda authored Aug 2, 2020
1 parent c80ae0e commit b8d0085
Show file tree
Hide file tree
Showing 122 changed files with 1,222 additions and 897 deletions.
236 changes: 118 additions & 118 deletions core/controllers/acl_decorators.py

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions core/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _reload_exploration(self, exploration_id):
exploration_id: str. The exploration id.
Raises:
Exception: Cannot reload an exploration in production.
Exception. Cannot reload an exploration in production.
"""
if constants.DEV_MODE:
logging.info(
Expand Down Expand Up @@ -354,8 +354,8 @@ def _load_dummy_new_structures_data(self):
attached to each skill.
Raises:
Exception: Cannot load new structures data in production mode.
Exception: User does not have enough rights to generate data.
Exception. Cannot load new structures data in production mode.
Exception. User does not have enough rights to generate data.
"""
if constants.DEV_MODE:
if self.user.role != feconf.ROLE_ID_ADMIN:
Expand Down Expand Up @@ -501,8 +501,8 @@ def _generate_dummy_skill_and_questions(self):
linked to the skill.
Raises:
Exception: Cannot load new structures data in production mode.
Exception: User does not have enough rights to generate data.
Exception. Cannot load new structures data in production mode.
Exception. User does not have enough rights to generate data.
"""
if constants.DEV_MODE:
if self.user.role != feconf.ROLE_ID_ADMIN:
Expand Down Expand Up @@ -537,7 +537,7 @@ def _reload_collection(self, collection_id):
collection_id: str. The collection id.
Raises:
Exception: Cannot reload a collection in production.
Exception. Cannot reload a collection in production.
"""
if constants.DEV_MODE:
logging.info(
Expand All @@ -562,7 +562,7 @@ def _generate_dummy_explorations(
be published.
Raises:
Exception: Environment is not DEVMODE.
Exception. Environment is not DEVMODE.
"""

if constants.DEV_MODE:
Expand Down
19 changes: 9 additions & 10 deletions core/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def _clear_login_cookies(response_headers):
"""Clears login cookies from the given response headers.
Args:
response_headers: webapp2.ResponseHeaders.
Response headers are used to give a more detailed
context of the response.
response_headers: webapp2.ResponseHeaders. Response headers are used
to give a more detailed context of the response.
"""
# App Engine sets the ACSID cookie for http:// and the SACSID cookie
# for https:// . We just unset both below. We also unset dev_appserver_login
Expand Down Expand Up @@ -230,8 +229,8 @@ def dispatch(self):
"""Overrides dispatch method in webapp2 superclass.
Raises:
Exception: The CSRF token is missing.
UnauthorizedUserException: The CSRF token is invalid.
Exception. The CSRF token is missing.
UnauthorizedUserException. The CSRF token is invalid.
"""
# If the request is to the old demo server, redirect it permanently to
# the new demo server.
Expand Down Expand Up @@ -294,31 +293,31 @@ def get(self, *args, **kwargs): # pylint: disable=unused-argument
"""Base method to handle GET requests.
Raises:
PageNotFoundException: Page not found error (error code 404).
PageNotFoundException. Page not found error (error code 404).
"""
raise self.PageNotFoundException

def post(self, *args): # pylint: disable=unused-argument
"""Base method to handle POST requests.
Raises:
PageNotFoundException: Page not found error (error code 404).
PageNotFoundException. Page not found error (error code 404).
"""
raise self.PageNotFoundException

def put(self, *args): # pylint: disable=unused-argument
"""Base method to handle PUT requests.
Raises:
PageNotFoundException: Page not found error (error code 404).
PageNotFoundException. Page not found error (error code 404).
"""
raise self.PageNotFoundException

def delete(self, *args): # pylint: disable=unused-argument
"""Base method to handle DELETE requests.
Raises:
PageNotFoundException: Page not found error (error code 404).
PageNotFoundException. Page not found error (error code 404).
"""
raise self.PageNotFoundException

Expand Down Expand Up @@ -555,7 +554,7 @@ def _create_token(cls, user_id, issued_on):
issued_on: float. The timestamp at which the token was issued.
Returns:
str: The generated CSRF token.
str. The generated CSRF token.
"""
cls.init_csrf_secret()

Expand Down
4 changes: 2 additions & 2 deletions core/controllers/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _publish_exploration(self, exploration_id):
exploration_id: str. Id of the exploration.
Raises:
InvalidInputException: Given exploration is invalid.
InvalidInputException. Given exploration is invalid.
"""
exploration = exp_fetchers.get_exploration_by_id(exploration_id)
try:
Expand Down Expand Up @@ -342,7 +342,7 @@ def put(self, exploration_id):
exploration_id: str. The exploration id.
Raises:
InvalidInputException: Invalid message type.
InvalidInputException. Invalid message type.
"""

mute = self.payload.get('mute')
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/skill_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _require_valid_version(version_from_payload, skill_version):
in the backend.
Raises:
Exception: Invalid input.
Exception. Invalid input.
"""
if version_from_payload is None:
raise base.BaseHandler.InvalidInputException(
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/suggestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _require_valid_suggestion_and_target_types(
suggestion_type: str. The type of the suggestion.
Raises:
InvalidInputException: If the given target_type of suggestion_type
InvalidInputException. If the given target_type of suggestion_type
are invalid.
"""
if target_type not in suggestion_models.TARGET_TYPE_CHOICES:
Expand Down
6 changes: 3 additions & 3 deletions core/domain/activity_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def validate(self):
are valid.
Raises:
Exception: The activity type is invalid.
Exception. The activity type is invalid.
"""
if (self.type != constants.ACTIVITY_TYPE_EXPLORATION and
self.type != constants.ACTIVITY_TYPE_COLLECTION):
Expand All @@ -67,7 +67,7 @@ def to_dict(self):
"""Returns a dict representing this ActivityReference domain object.
Returns:
A dict, mapping type and id of a ActivityReference
dict. A dict, mapping type and id of an ActivityReference
instance to corresponding keys 'type' and 'id'.
"""
return {
Expand Down Expand Up @@ -98,7 +98,7 @@ def validate(self):
self.activity_reference_list are valid.
Raises:
Exception: Any ActivityReference in self.activity_reference_list
Exception. Any ActivityReference in self.activity_reference_list
is invalid.
"""
for reference in self.activity_reference_list:
Expand Down
22 changes: 12 additions & 10 deletions core/domain/activity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def get_featured_activity_references():
"""Gets a list of ActivityReference domain models.
Returns:
A list of all ActivityReference domain objects that are
currently featured.
list(ActivityReference). A list of all ActivityReference domain objects
that are currently featured.
"""
featured_model_instance = (
activity_models.ActivityReferencesModel.get_or_create(
Expand All @@ -49,11 +49,12 @@ def update_featured_activity_references(featured_activity_references):
"""Updates the current list of featured activity references.
Args:
featured_activity_references: A list of ActivityReference domain
objects representing the full list of 'featured' activities.
featured_activity_references: list(ActivityReference). A list of
ActivityReference domain objects representing the full list of
'featured' activities.
Raises:
Exception: The input list of ActivityReference domain objects has
Exception. The input list of ActivityReference domain objects has
duplicates.
"""
for activity_reference in featured_activity_references:
Expand Down Expand Up @@ -119,15 +120,16 @@ def split_by_type(activity_references):
in the input list.
Args:
activity_references: A list of ActivityReference domain objects.
activity_references: list(ActivityReference). The domain object
containing exploration ids and collection ids.
Returns:
A 2-tuple whose first element is a list of all exploration
ids represented in the input list, and whose second element
is a list of all collection ids represented in the input list.
tuple(list(str), list(str)). A 2-tuple whose first element is a list of
all exploration ids represented in the input list, and whose second
element is a list of all collection ids represented in the input list.
Raises:
Exception: The activity reference type is invalid.
Exception. The activity reference type is invalid.
"""
exploration_ids, collection_ids = [], []
for activity_reference in activity_references:
Expand Down
4 changes: 2 additions & 2 deletions core/domain/change_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(self, change_dict):
change_dict: dict. The dict containing cmd name and attributes.
Raises:
ValidationError: The given change_dict is not valid.
ValidationError. The given change_dict is not valid.
"""
self.validate_dict(change_dict)

Expand Down Expand Up @@ -177,7 +177,7 @@ def to_dict(self):
"""Returns a dict representing the BaseChange domain object.
Returns:
A dict, mapping all fields of BaseChange instance.
dict. A dict, mapping all fields of BaseChange instance.
"""
base_change_dict = {}
base_change_dict['cmd'] = self.cmd
Expand Down
6 changes: 3 additions & 3 deletions core/domain/classifier_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def to_dict(self):
"""Constructs a dict representation of training job domain object.
Returns:
A dict representation of training job domain object.
dict. A dict representation of training job domain object.
"""

return {
Expand All @@ -302,7 +302,7 @@ def to_player_dict(self):
algorithm_id, classifier_data and data_schema_version.
Returns:
A dict containing training job domain object's algorithm_id,
dict. A dict containing training job domain object's algorithm_id,
classifier_data and data_schema_version.
"""

Expand Down Expand Up @@ -476,7 +476,7 @@ def to_dict(self):
domain object.
Returns:
A dict representation of TrainingJobExplorationMapping domain
dict. A dict representation of TrainingJobExplorationMapping domain
object.
"""

Expand Down
8 changes: 4 additions & 4 deletions core/domain/classifier_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def convert_strings_to_float_numbers_in_classifier_data(
Raises:
Exception. If classifier data contains an object whose type is other
than integer, string, dict or list.
than integer, string, dict or list.
Returns:
dict|list|string|int|float. Original classifier data dict with
Expand Down Expand Up @@ -256,7 +256,7 @@ def get_classifier_training_job_by_id(job_id):
classifier training job.
Raises:
Exception: Entity for class ClassifierTrainingJobModel with id not
Exception. Entity for class ClassifierTrainingJobModel with id not
found.
"""
classifier_training_job_model = (
Expand All @@ -270,7 +270,7 @@ def _update_classifier_training_jobs_status(job_ids, status):
"""Checks for the existence of the model and then updates it.
Args:
job_ids: list(str). list of ID of the ClassifierTrainingJob domain
job_ids: list(str). List of ID of the ClassifierTrainingJob domain
objects.
status: str. The status to which the job needs to be updated.
Expand Down Expand Up @@ -312,7 +312,7 @@ def mark_training_jobs_failed(job_ids):
"""Updates the training job's status to failed.
Args:
job_ids: list(str). list of ID of the ClassifierTrainingJobs.
job_ids: list(str). List of ID of the ClassifierTrainingJobs.
"""
_update_classifier_training_jobs_status(
job_ids, feconf.TRAINING_JOB_STATUS_FAILED)
Expand Down
Loading

0 comments on commit b8d0085

Please sign in to comment.