Repository: oppia/oppia

Issue:
Update docstrings in the Python backend code to follow the style guide.
We've been a bit lax about adding docstrings to code in the backend. Instead, we should be following the style guide: https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments -- docstrings should define args, return values, exceptions, etc. The aim of this issue is to ensure that the backend code is properly documented; we will tackle this on a file-by-file basis.

Note: if you're a new contributor, this issue is a particularly good introductory one to tackle, since it will require reading, understanding and documenting the purpose of a file in the codebase, and help you get acquainted with how the Oppia backend is structured. It's important that you're able to communicate and write clearly, though!

Some useful tips:
-  Please follow our [style guide](https://github.com/oppia/oppia/wiki/Coding-style-guide#general) (and also the [Google Python style guide](https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments)) when writing docstrings. Make sure to follow the patterns established there as closely as possible, including spacing, capitalization and punctuation. Also, it's a good idea to look at some of the existing files (see below) to get a sense of the correct format -- we recommend following this closely in order to maintain uniformity across the codebase.
- If applicable, make sure that the docstrings for all functions correctly specify the args, return values, etc. If a function has no args, you can omit the Args section; if it has no return value, you can omit the Returns section.
- If a docstring is not present in the code, or the existing one is too vague for you to understand what's going on just by looking at it, then it should be rewritten to be more clear. You'll often need to read the code as well, and do a grep on the callsites to see how it's being used, in order to get a clear understanding of what it's doing. This is good practice for learning how to navigate the codebase, and is an intended part of this project.
- If you feel that parts of the codebase are unclear or incorrectly factored, please feel free to bring this up! The whole point of docstrings is to improve code health and accessibility for new developers, so if you spot other things that can be done in service of that aim, we should also look into doing that.

**Completed:**
- [x] core.controllers.base @shaz13 
- [x] core.controllers.cron @saeedjassani
- [x] core.controllers.reader @96mohitm
- [x] core.domain.activity_domain @andromfins
- [x] core.domain.activity_services @souravsingh
- [x] core.domain.classifier_services @andromfins 
- [x] core.domain.collection_domain @domevit
- [x] core.domain.collection_services @kahkhang 
- [x] core.domain.config_services @vibhor98 
- [x] core.domain.email_manager @Oishikatta 
- [x] core.domain.exp_domain @domevit
- [x] core.domain.exp_services @DubeySandeep
- [x] core.domain.feedback_domain @terrameijar 
- [x] core.domain.feedback_jobs_continuous
- [x] core.domain.feedback_services @andimeo
- [x] core.domain.fs_domain @kartik-25 
- [x] core.domain.html_cleaner @seanlip
- [x] core.domain.param_domain @rohan-gulati
- [x] core.domain.rating_services @BojOnTheBeat 
- [x] core.domain.rights_manager @ayejay
- [x] core.domain.stats_domain @Arunabh98
- [x] core.domain.stats_jobs_continuous @Arunabh98 
- [x] core.domain.stats_jobs_one_off @zpuller
- [x] core.domain.stats_services @manoj-makkuboy 
- [x] core.domain.subscription_services @vibhor98 
- [x] core.domain.summary_services @domevit 
- [x] core.domain.user_jobs_continuous @shubha1593 
- [x] core.domain.user_services @Nalinc 
- [x] core.domain.value_generators_domain @meetsha 
- [x] core.jobs @brianrodri
- [x] core.platform.app_identity.gae_app_identity_services @ubhisat
- [x] core.platform.models @pranavsid98 
- [x] core.platform.transactions.gae_transaction_services @ubhisat
- [x] core.storage.base_model.gae_models @vojtechjelinek
- [x] core.storage.collection.gae_models @kaggis
- [x] core.storage.email.gae_models @rajan-garg
- [x] core.storage.exploration.gae_models @kirankonduru
- [x] core.storage.feedback.gae_models @naveenshukla
- [x] core.storage.file.gae_models @Ian91 
- [x] core.storage.job.gae_models @sasacocic
- [x] core.storage.statistics.gae_models @abhishekarya286
- [x] core.storage.user.gae_models @Anthony-Alridge 
- [x] core.tests.test_util_jobs @seanlip
- [x] core.tests.test_utils @vibhor98
- [x] utils @yashLadha 
Update docstrings in the Python backend code to follow the style guide.
We've been a bit lax about adding docstrings to code in the backend. Instead, we should be following the style guide: https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments -- docstrings should define args, return values, exceptions, etc. The aim of this issue is to ensure that the backend code is properly documented; we will tackle this on a file-by-file basis.

Note: if you're a new contributor, this issue is a particularly good introductory one to tackle, since it will require reading, understanding and documenting the purpose of a file in the codebase, and help you get acquainted with how the Oppia backend is structured. It's important that you're able to communicate and write clearly, though!

Some useful tips:
-  Please follow our [style guide](https://github.com/oppia/oppia/wiki/Coding-style-guide#general) (and also the [Google Python style guide](https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments)) when writing docstrings. Make sure to follow the patterns established there as closely as possible, including spacing, capitalization and punctuation. Also, it's a good idea to look at some of the existing files (see below) to get a sense of the correct format -- we recommend following this closely in order to maintain uniformity across the codebase.
- If applicable, make sure that the docstrings for all functions correctly specify the args, return values, etc. If a function has no args, you can omit the Args section; if it has no return value, you can omit the Returns section.
- If a docstring is not present in the code, or the existing one is too vague for you to understand what's going on just by looking at it, then it should be rewritten to be more clear. You'll often need to read the code as well, and do a grep on the callsites to see how it's being used, in order to get a clear understanding of what it's doing. This is good practice for learning how to navigate the codebase, and is an intended part of this project.
- If you feel that parts of the codebase are unclear or incorrectly factored, please feel free to bring this up! The whole point of docstrings is to improve code health and accessibility for new developers, so if you spot other things that can be done in service of that aim, we should also look into doing that.

**Completed:**
- [x] core.controllers.base @shaz13 
- [x] core.controllers.cron @saeedjassani
- [x] core.controllers.reader @96mohitm
- [x] core.domain.activity_domain @andromfins
- [x] core.domain.activity_services @souravsingh
- [x] core.domain.classifier_services @andromfins 
- [x] core.domain.collection_domain @domevit
- [x] core.domain.collection_services @kahkhang 
- [x] core.domain.config_services @vibhor98 
- [x] core.domain.email_manager @Oishikatta 
- [x] core.domain.exp_domain @domevit
- [x] core.domain.exp_services @DubeySandeep
- [x] core.domain.feedback_domain @terrameijar 
- [x] core.domain.feedback_jobs_continuous
- [x] core.domain.feedback_services @andimeo
- [x] core.domain.fs_domain @kartik-25 
- [x] core.domain.html_cleaner @seanlip
- [x] core.domain.param_domain @rohan-gulati
- [x] core.domain.rating_services @BojOnTheBeat 
- [x] core.domain.rights_manager @ayejay
- [x] core.domain.stats_domain @Arunabh98
- [x] core.domain.stats_jobs_continuous @Arunabh98 
- [x] core.domain.stats_jobs_one_off @zpuller
- [x] core.domain.stats_services @manoj-makkuboy 
- [x] core.domain.subscription_services @vibhor98 
- [x] core.domain.summary_services @domevit 
- [x] core.domain.user_jobs_continuous @shubha1593 
- [x] core.domain.user_services @Nalinc 
- [x] core.domain.value_generators_domain @meetsha 
- [x] core.jobs @brianrodri
- [x] core.platform.app_identity.gae_app_identity_services @ubhisat
- [x] core.platform.models @pranavsid98 
- [x] core.platform.transactions.gae_transaction_services @ubhisat
- [x] core.storage.base_model.gae_models @vojtechjelinek
- [x] core.storage.collection.gae_models @kaggis
- [x] core.storage.email.gae_models @rajan-garg
- [x] core.storage.exploration.gae_models @kirankonduru
- [x] core.storage.feedback.gae_models @naveenshukla
- [x] core.storage.file.gae_models @Ian91 
- [x] core.storage.job.gae_models @sasacocic
- [x] core.storage.statistics.gae_models @abhishekarya286
- [x] core.storage.user.gae_models @Anthony-Alridge 
- [x] core.tests.test_util_jobs @seanlip
- [x] core.tests.test_utils @vibhor98
- [x] utils @yashLadha 


Discussion:
@seanlip I would like to work in the issue.

Hi @souravsingh, do you think you could finish up #2051 first, please? Thanks! 

@seanlip I would like to work on this issue.

Hi @andromfins -- now that you've had a go at writing docstrings for a single class, would you mind picking one or two other files and doing the same thing for those? Let me know which ones you pick, so that I can mark you off against them.

Thanks!

Hi, i'm working on **core.domain.classifier_services**.

OK, thanks @andromfins! 

@seanlip Can I take a stab at other file to add docstrings?

Yep, sounds good. Could you take core.domain.html_cleaner? Thanks!

@andromfins -- are you still working on this?

  @seanlip Yes!

I would like to work on `core.domain.stats_domain`

@Arunabh98 assigned you on `core.domain.stats_domain`

@seanlip I would like to work in the issue.

Hi @souravsingh, do you think you could finish up #2051 first, please? Thanks! 

@seanlip I would like to work on this issue.

Hi @andromfins -- now that you've had a go at writing docstrings for a single class, would you mind picking one or two other files and doing the same thing for those? Let me know which ones you pick, so that I can mark you off against them.

Thanks!

Hi, i'm working on **core.domain.classifier_services**.

OK, thanks @andromfins! 

@seanlip Can I take a stab at other file to add docstrings?

Yep, sounds good. Could you take core.domain.html_cleaner? Thanks!

@andromfins -- are you still working on this?

  @seanlip Yes!

I would like to work on `core.domain.stats_domain`

@Arunabh98 assigned you on `core.domain.stats_domain`


Resolving patch:
diff --git a/core/storage/base_model/gae_models.py b/core/storage/base_model/gae_models.py
--- a/core/storage/base_model/gae_models.py
+++ b/core/storage/base_model/gae_models.py
@@ -62,21 +62,21 @@ class EntityNotFoundError(Exception):
 
     @classmethod
     def get(cls, entity_id, strict=True):
-        """Gets an entity by id. Fails noisily if strict == True.
+        """Gets an entity by id.
 
         Args:
-          entity_id: str. The id of the entity.
-          strict: bool. Whether to fail noisily if no entity with the given id
-            exists in the datastore.
+            entity_id: str.
+            strict: bool. Whether to fail noisily if no entity with the given id
+                exists in the datastore. Default is True.
 
         Returns:
-          None, if strict == False and no undeleted entity with the given id
-          exists in the datastore. Otherwise, the entity instance that
-          corresponds to the given id.
+            None, if strict == False and no undeleted entity with the given id
+            exists in the datastore. Otherwise, the entity instance that
+            corresponds to the given id.
 
         Raises:
-        - base_models.BaseModel.EntityNotFoundError: if strict == True and
-            no undeleted entity with the given id exists in the datastore.
+            base_models.BaseModel.EntityNotFoundError: if strict == True and
+                no undeleted entity with the given id exists in the datastore.
         """
         entity = cls.get_by_id(entity_id)
         if entity and entity.deleted:
@@ -89,15 +89,23 @@ def get(cls, entity_id, strict=True):
         return entity
 
     def put(self):
+        """Stores this entity's data."""
         super(BaseModel, self).put()
 
     @classmethod
     def get_multi(cls, entity_ids, include_deleted=False):
-        """Returns a list, each entry of which is the instance model
-        corresponding to the entity_id, except for the following two cases (in
-        which the corresponding entry is None instead):
-          - the instance is not found
-          - the instance has been deleted, and `include_deleted` is True.
+        """Gets list of entities by list of ids.
+
+        Args:
+            entity_ids: list(str).
+            include_deleted: bool. Whether to include deleted entities in the
+                return list. Default is False.
+
+        Returns:
+            list(*|None). A list that contains model instances that match
+            the corresponding entity_ids in the input list. If an instance is
+            not found, or it has been deleted and include_deleted is False,
+            then the corresponding entry is None.
         """
         entity_keys = [ndb.Key(cls, entity_id) for entity_id in entity_ids]
         entities = ndb.get_multi(entity_keys)
@@ -109,20 +117,30 @@ def get_multi(cls, entity_ids, include_deleted=False):
 
     @classmethod
     def put_multi(cls, entities):
-        return ndb.put_multi(entities)
+        """Stores the given ndb.Model instances.
+
+        Args:
+            entities: list(ndb.Model).
+        """
+        ndb.put_multi(entities)
 
     def delete(self):
+        """Deletes this instance."""
         super(BaseModel, self).key.delete()
 
     @classmethod
-    def get_all(cls, include_deleted_entities=False):
-        """Returns a filterable iterable of all entities of this class.
+    def get_all(cls, include_deleted=False):
+        """Gets iterable of all entities of this class.
 
-        If include_deleted_entities is True then entities that have been marked
-        deleted are returned as well.
+        Args:
+            include_deleted: bool. If True, then entities that have been marked
+                deleted are returned as well. Defaults to False.
+
+        Returns:
+            iterable. Filterable iterable of all entities of this class.
         """
         query = cls.query()
-        if not include_deleted_entities:
+        if not include_deleted:
             query = query.filter(cls.deleted == False)  # pylint: disable=singleton-comparison
         return query
 
@@ -134,15 +152,15 @@ def get_new_id(cls, entity_name):
         entity.
 
         Args:
-          entity_name: the name of the entity. Coerced to a utf-8 encoded
-            string. Defaults to ''.
+            entity_name: The name of the entity. Coerced to a utf-8 encoded
+                string. Defaults to ''.
 
         Returns:
-          str: a new unique id for this entity class.
+            str. New unique id for this entity class.
 
         Raises:
-        - Exception: if an id cannot be generated within a reasonable number
-            of attempts.
+            Exception: An ID cannot be generated within a reasonable number
+                of attempts.
         """
         try:
             entity_name = unicode(entity_name).encode('utf-8')
@@ -161,6 +179,28 @@ def get_new_id(cls, entity_name):
     @classmethod
     def _fetch_page_sorted_by_last_updated(
             cls, query, page_size, urlsafe_start_cursor):
+        """Fetches a page of entities sorted by their last_updated attribute in
+        descending order (newly updated first).
+
+        Args:
+            query: ndb.Query.
+            page_size: int. The maximum number of entities to be returned.
+            urlsafe_start_cursor: str or None. If provided, the list of returned
+                entities starts from this datastore cursor. Otherwise,
+                the returned entities start from the beginning of the full
+                list of entities.
+
+        Returns:
+            3-tuple of (results, cursor, more) as described in fetch_page() at:
+            https://developers.google.com/appengine/docs/python/ndb/queryclass,
+            where:
+                results: List of query results.
+                cursor: str or None. A query cursor pointing to the next batch
+                    of results. If there are no more results, this will be None.
+                more: bool. If True, there are (probably) more results after
+                    this batch. If False, there are no further results after
+                    this batch.
+        """
         if urlsafe_start_cursor:
             start_cursor = datastore_query.Cursor(urlsafe=urlsafe_start_cursor)
         else:
@@ -224,16 +264,23 @@ def _require_not_marked_deleted(self):
             raise Exception('This model instance has been deleted.')
 
     def _compute_snapshot(self):
-        """Generates a snapshot (a Python dict) from the model fields."""
+        """Generates a snapshot (dict) from the model property values."""
         return self.to_dict(exclude=['created_on', 'last_updated'])
 
     def _reconstitute(self, snapshot_dict):
-        """Makes this instance into a reconstitution of the given snapshot."""
         self.populate(**snapshot_dict)
         return self
 
     def _reconstitute_from_snapshot_id(self, snapshot_id):
-        """Makes this instance into a reconstitution of the given snapshot."""
+        """Gets a reconstituted instance of this model class, based on the given
+        snapshot id.
+
+        Args:
+            snapshot_id: str.
+
+        Returns:
+            VersionedModel. Reconstituted instance.
+        """
         snapshot_model = self.SNAPSHOT_CONTENT_CLASS.get(snapshot_id)
         snapshot_dict = snapshot_model.content
         reconstituted_model = self._reconstitute(snapshot_dict)
@@ -250,11 +297,42 @@ def _reconstitute_from_snapshot_id(self, snapshot_id):
 
     @classmethod
     def _get_snapshot_id(cls, instance_id, version_number):
+        """Gets a unique snapshot id for this instance and version.
+
+        Args:
+            instance_id: str.
+            version_number: int.
+
+        Returns:
+            str. The unique snapshot id corresponding to the given instance and
+            version.
+        """
         return '%s%s%s' % (
             instance_id, _VERSION_DELIMITER, version_number)
 
     def _trusted_commit(
             self, committer_id, commit_type, commit_message, commit_cmds):
+        """Evaluates and executes commit. Main function for all commit types.
+
+        Args:
+            committer_id: str. The user_id of the user who committed the change.
+            commit_type: str. Unique identifier of commit type. Possible values
+                are in COMMIT_TYPE_CHOICES.
+            commit_message: str.
+            commit_cmds: list(dict). A list of commands, describing changes
+                made in this model, should give sufficient information to
+                reconstruct the commit. Dict always contains:
+                    cmd: str. Unique command.
+                And then additional arguments for that command. For example:
+
+                {'cmd': 'AUTO_revert_version_number'
+                 'version_number': 4}
+
+        Raises:
+            Exception: No snapshot metadata class has been defined.
+            Exception: No snapshot content class has been defined.
+            Exception: commit_cmds is not a list of dicts.
+        """
         if self.SNAPSHOT_METADATA_CLASS is None:
             raise Exception('No snapshot metadata class defined.')
         if self.SNAPSHOT_CONTENT_CLASS is None:
@@ -285,6 +363,18 @@ def _trusted_commit(
             [snapshot_metadata_instance, snapshot_content_instance, self])
 
     def delete(self, committer_id, commit_message, force_deletion=False):
+        """Deletes this model instance.
+
+        Args:
+            committer_id: str. The user_id of the user who committed the change.
+            commit_message: str.
+            force_deletion: bool. If True this model is deleted
+                completely from storage, otherwise it is only marked as deleted.
+                Default is False.
+
+        Raises:
+            Exception: This model instance has been already deleted.
+        """
         if force_deletion:
             current_version = self.version
 
@@ -323,8 +413,21 @@ def put(self, *args, **kwargs):
     def commit(self, committer_id, commit_message, commit_cmds):
         """Saves a version snapshot and updates the model.
 
-        commit_cmds should give sufficient information to reconstruct the
-        commit.
+        Args:
+            committer_id: str. The user_id of the user who committed the change.
+            commit_message: str.
+            commit_cmds: list(dict). A list of commands, describing changes
+                made in this model, should give sufficient information to
+                reconstruct the commit. Dict always contains:
+                    cmd: str. Unique command.
+                And then additional arguments for that command. For example:
+
+                {'cmd': 'AUTO_revert_version_number'
+                 'version_number': 4}
+
+        Raises:
+            Exception: This model instance has been already deleted.
+            Exception: commit_cmd is in invalid format.
         """
         self._require_not_marked_deleted()
 
@@ -346,6 +449,18 @@ def commit(self, committer_id, commit_message, commit_cmds):
 
     @classmethod
     def revert(cls, model, committer_id, commit_message, version_number):
+        """Reverts model to previous version.
+
+        Args:
+            model: VersionedModel.
+            committer_id: str. The user_id of the user who committed the change.
+            commit_message: str.
+            version_number: int. Version to revert to.
+
+        Raises:
+            Exception: This model instance has been deleted.
+            Exception: Reverting is not allowed on this model.
+        """
         model._require_not_marked_deleted()  # pylint: disable=protected-access
 
         if not model.ALLOW_REVERT:
@@ -384,23 +499,44 @@ def revert(cls, model, committer_id, commit_message, version_number):
         # pylint: enable=protected-access
 
     @classmethod
-    def get_version(cls, model_instance_id, version_number):
-        """Returns a model instance representing the given version.
+    def get_version(cls, entity_id, version_number):
+        """Gets model instance representing the given version.
 
         The snapshot content is used to populate this model instance. The
         snapshot metadata is not used.
+
+        Args:
+            entity_id: str.
+            version_number: int.
+
+        Returns:
+            VersionedModel. Model instance representing given version.
+
+        Raises:
+            Exception: This model instance has been deleted.
         """
         # pylint: disable=protected-access
-        cls.get(model_instance_id)._require_not_marked_deleted()
+        cls.get(entity_id)._require_not_marked_deleted()
 
-        snapshot_id = cls._get_snapshot_id(model_instance_id, version_number)
-        return cls(id=model_instance_id)._reconstitute_from_snapshot_id(
+        snapshot_id = cls._get_snapshot_id(entity_id, version_number)
+        return cls(id=entity_id)._reconstitute_from_snapshot_id(
             snapshot_id)
         # pylint: enable=protected-access
 
     @classmethod
     def get(cls, entity_id, strict=True, version=None):
-        """Gets an entity by id. Fails noisily if strict == True."""
+        """Gets model instance.
+
+        Args:
+            entity_id: str.
+            strict: bool. Whether to fail noisily if no entity with the given id
+                exists in the datastore. Default is True.
+            version: int. Version we want to get. Default is None.
+
+        Returns:
+            VersionedModel. If version is None, get the newest version of the
+            model. Otherwise, get the specified version.
+        """
         if version is None:
             return super(VersionedModel, cls).get(entity_id, strict=strict)
         else:
@@ -409,14 +545,42 @@ def get(cls, entity_id, strict=True, version=None):
     @classmethod
     def get_snapshots_metadata(
             cls, model_instance_id, version_numbers, allow_deleted=False):
-        """Returns a list of dicts, each representing a model snapshot.
+        """Gets a list of dicts, each representing a model snapshot.
 
         One dict is returned for each version number in the list of version
         numbers requested. If any of the version numbers does not exist, an
         error is raised.
 
-        If `allow_deleted` is False, an error is raised if the current model
-        has been deleted.
+        Args:
+            model_instance_id: str. Id of requested model.
+            version_numbers: list(int). List of version numbers.
+            allow_deleted: bool. If is False, an error is raised if the current
+                model has been deleted. Default is False.
+
+        Returns:
+            list(dict). Each dict contains metadata for a particular snapshot.
+            It has the following keys:
+                committer_id: str. The user_id of the user who committed the
+                    change.
+                commit_message: str.
+                commit_cmds: list(dict). A list of commands, describing changes
+                    made in this model, should give sufficient information to
+                    reconstruct the commit. Dict always contains:
+                        cmd: str. Unique command.
+                    And then additional arguments for that command. For example:
+
+                    {'cmd': 'AUTO_revert_version_number'
+                     'version_number': 4}
+
+                commit_type: str. Unique identifier of commit type. Possible
+                    values are in COMMIT_TYPE_CHOICES.
+                version_number: int.
+                created_on_ms: float. Snapshot creation time in milliseconds
+                    since the Epoch.
+
+        Raises:
+            Exception: There is no model instance corresponding to at least one
+                of the given version numbers.
         """
         # pylint: disable=protected-access
         if not allow_deleted:
@@ -464,12 +628,20 @@ class BaseSnapshotMetadataModel(BaseModel):
     # Represented as a list of dicts.
     commit_cmds = ndb.JsonProperty(indexed=False)
 
-    # Get the instance id from the versioned id (see
-    # _get_snapshot_id in VersionedModel)
     def get_unversioned_instance_id(self):
+        """Gets the instance id from the snapshot id.
+
+        Returns:
+            str. Instance id part of snapshot id.
+        """
         return self.id[:self.id.rfind(_VERSION_DELIMITER)]
 
     def get_version_string(self):
+        """Gets the version number from the snapshot id.
+
+        Returns:
+            str. Version number part of snapshot id.
+        """
         return self.id[self.id.rfind(_VERSION_DELIMITER) + 1:]
 
 
@@ -482,12 +654,20 @@ class BaseSnapshotContentModel(BaseModel):
     # The snapshot content, as a JSON blob.
     content = ndb.JsonProperty(indexed=False)
 
-    # Get the instance id from the versioned id (see
-    # _get_snapshot_id in VersionedModel)
     def get_unversioned_instance_id(self):
+        """Gets the instance id from the snapshot id.
+
+        Returns:
+            str. Instance id part of snapshot id.
+        """
         return self.id[:self.id.rfind(_VERSION_DELIMITER)]
 
     def get_version_string(self):
+        """Gets the version number from the snapshot id.
+
+        Returns:
+            str. Version number part of snapshot id.
+        """
         return self.id[self.id.rfind(_VERSION_DELIMITER) + 1:]
 
 
diff --git a/core/storage/feedback/gae_models.py b/core/storage/feedback/gae_models.py
--- a/core/storage/feedback/gae_models.py
+++ b/core/storage/feedback/gae_models.py
@@ -217,7 +217,7 @@ def get_message_count(cls, exploration_id, thread_id):
         """
         full_thread_id = FeedbackThreadModel.generate_full_thread_id(
             exploration_id, thread_id)
-        return cls.get_all(include_deleted_entities=True).filter(
+        return cls.get_all(include_deleted=True).filter(
             cls.thread_id == full_thread_id).count()
 
     @classmethod


Test patch:
diff --git a/core/domain/collection_services_test.py b/core/domain/collection_services_test.py
--- a/core/domain/collection_services_test.py
+++ b/core/domain/collection_services_test.py
@@ -525,13 +525,13 @@ def test_soft_deletion_of_collections(self):
         self.assertIn(self.COLLECTION_ID, [
             collection.id
             for collection in collection_models.CollectionModel.get_all(
-                include_deleted_entities=True)])
+                include_deleted=True)])
 
         # The collection summary is deleted, however.
         self.assertNotIn(self.COLLECTION_ID, [
             collection.id
             for collection in collection_models.CollectionSummaryModel.get_all(
-                include_deleted_entities=True)])
+                include_deleted=True)])
 
     def test_hard_deletion_of_collections(self):
         """Test that hard deletion of collections works correctly."""
@@ -553,7 +553,7 @@ def test_hard_deletion_of_collections(self):
         self.assertNotIn(self.COLLECTION_ID, [
             collection.id
             for collection in collection_models.CollectionModel.get_all(
-                include_deleted_entities=True)])
+                include_deleted=True)])
 
     def test_summaries_of_hard_deleted_collections(self):
         """Test that summaries of hard deleted collections are
@@ -574,7 +574,7 @@ def test_summaries_of_hard_deleted_collections(self):
         self.assertNotIn(self.COLLECTION_ID, [
             collection.id
             for collection in collection_models.CollectionSummaryModel.get_all(
-                include_deleted_entities=True)])
+                include_deleted=True)])
 
     def test_collections_are_removed_from_index_when_deleted(self):
         """Tests that deleted collections are removed from the search index."""
diff --git a/core/domain/exp_services_test.py b/core/domain/exp_services_test.py
--- a/core/domain/exp_services_test.py
+++ b/core/domain/exp_services_test.py
@@ -376,14 +376,14 @@ def test_soft_deletion_of_explorations(self):
         self.assertIn(
             self.EXP_ID,
             [exp.id for exp in exp_models.ExplorationModel.get_all(
-                include_deleted_entities=True)]
+                include_deleted=True)]
         )
 
         # The exploration summary is deleted however
         self.assertNotIn(
             self.EXP_ID,
             [exp.id for exp in exp_models.ExpSummaryModel.get_all(
-                include_deleted_entities=True)]
+                include_deleted=True)]
         )
 
     def test_hard_deletion_of_explorations(self):
@@ -406,7 +406,7 @@ def test_hard_deletion_of_explorations(self):
         self.assertNotIn(
             self.EXP_ID,
             [exp.id for exp in exp_models.ExplorationModel.get_all(
-                include_deleted_entities=True)]
+                include_deleted=True)]
         )
 
     def test_summaries_of_hard_deleted_explorations(self):
@@ -427,7 +427,7 @@ def test_summaries_of_hard_deleted_explorations(self):
         self.assertNotIn(
             self.EXP_ID,
             [exp.id for exp in exp_models.ExpSummaryModel.get_all(
-                include_deleted_entities=True)]
+                include_deleted=True)]
         )
 
     def test_explorations_are_removed_from_index_when_deleted(self):