Skip to content

Commit

Permalink
Fix oppia#8165: implement 4 space indentation and 8 space indentation…
Browse files Browse the repository at this point in the history
… for docstrings (oppia#9654)

* Add tests to push coverage on StatesObjectFactory.ts to 100%

* Remove StatesObjectFactory from coverage

* Change fdescribe back to describe

* Fix linter issues

* Add outer if statement logic

* Add four/eight space indentation and tests

* Revert "Fix linter issues"

This reverts commit 540db31f8c4395a97718f858093967db2f6855d8.

* Revert "Change fdescribe back to describe"

This reverts commit 5c3d4997b5a27eb38f711c28ebc9fc0b56e6a2a0.

* Revert "Remove StatesObjectFactory from coverage"

This reverts commit 3a2d0614a04e535662e59ef38035329cd15068fc.

* Revert "Add tests to push coverage on StatesObjectFactory.ts to 100%"

This reverts commit fb68531b83c8247095d9d91afe1c4d25884e25ca.

* Fix linting and checks

* Change Return: to Returns: or else linter doesn't work

* Fix functionality and change up the requirements

* Make it possible to run file extensions on full path

* Fix some of the indentation issues caught by linter

* Add a new free form option and fix linting in exp_domain

* Fix linting in skill_services and prod_validation_jobs_one_off

* Fix linter in state_domain and stats_domain

* Fix smaller lint issues with rest of domain files

* Fix new lint issues

* Exp_domain linting fixes need some oversight

* Continue

* Add a new check for Args: docstring

* Revert "Exp_domain linting fixes need some oversight"

This reverts commit 1812e9d.

* Fix linting indentation in core/domain

* Fix lint issues in core/storage and core/platform

* Fix lint issues in rest of core

* Fix scripts linting

* Fix extensions linting

* Add misc linting

* Add new checks to pylint

* Readd all of the commented out checks

* fix fs domain

* Add tests

* Add comments

* Fix names and comments

* Final pass from look at github diff

* Fix more lint issues

* 2nd pass on PR

* Add tests for coverage

* Fix some more small indentation/description errors

* Address PR review comments

* Change the type to be more specific

* Address review comments

* Fix more list parameter definitions with no typeinfo

* Wrap the offending comment in jobs.py in a pylint-disable

* Address the review comments

* Accidentally removed a space when debugging that I added back in

* Address issues with PR

* Fix linting

* Fix more linting

* One more fix for syntax

* Increase coverage to 100% for backend tests and fix lint issue

* Fix lint issues from merge
  • Loading branch information
kevjumba authored Jun 29, 2020
1 parent 16154a2 commit 0d5e34d
Show file tree
Hide file tree
Showing 116 changed files with 1,737 additions and 1,103 deletions.
296 changes: 144 additions & 152 deletions core/controllers/acl_decorators.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/controllers/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get(self, page_context, page_identifier, asset_type, encoded_filename):
subtopic: topic_name of the topic that it is part of.
asset_type: str. Type of the asset, either image or audio.
encoded_filename: str. The asset filename. This
string is encoded in the frontend using encodeURIComponent().
string is encoded in the frontend using encodeURIComponent().
"""
if not constants.DEV_MODE:
raise self.PageNotFoundException
Expand Down
2 changes: 1 addition & 1 deletion core/controllers/suggestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_target_id_to_exploration_opportunity_dict(suggestions):
Returns:
dict. Dict mapping target_id to corresponding exploration opportunity
summary dict.
summary dict.
"""
target_ids = set([s.target_id for s in suggestions])
opportunities = (
Expand Down
6 changes: 4 additions & 2 deletions core/domain/action_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def get_all_actions(cls):
"""Get a list of instances of all actions.
Returns:
list. A list of all action class instances.
list(*). A list of all action class instances. Classes all have
"BaseLearnerActionSpec" as an ancestor class.
"""
if len(cls._actions) == 0:
cls._refresh()
Expand All @@ -91,7 +92,8 @@ def get_action_by_type(cls, action_type):
action_type: str. Type of the action.
Returns:
An instance of the corresponding action class.
*. An instance of the corresponding action class. This class has
"BaseLearnerActionSpec" as an ancestor class.
"""
if action_type not in cls._actions:
cls._refresh()
Expand Down
4 changes: 2 additions & 2 deletions core/domain/activity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def update_featured_activity_references(featured_activity_references):
objects representing the full list of 'featured' activities.
Raises:
Exception: The input list of ActivityReference
domain objects has duplicates.
Exception: The input list of ActivityReference domain objects has
duplicates.
"""
for activity_reference in featured_activity_references:
activity_reference.validate()
Expand Down
2 changes: 1 addition & 1 deletion core/domain/change_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def validate_dict(self, change_dict):
Args:
change_dict: dict. A dict of changes with keys as a cmd and the
attributes of a command.
attributes of a command.
Raises:
ValidationError. The change dict does not contain the cmd key,
Expand Down
70 changes: 36 additions & 34 deletions core/domain/classifier_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,39 +82,41 @@ def __init__(
"""Constructs a ClassifierTrainingJob domain object.
Args:
job_id: str. The unique id of the classifier training job.
algorithm_id: str. The id of the algorithm that will be used for
generating the classifier.
interaction_id: str. The id of the interaction to which the algorithm
belongs.
exp_id: str. The id of the exploration id that contains the state
for which classifier will be generated.
exp_version: int. The version of the exploration when
the training job was generated.
next_scheduled_check_time: datetime.datetime. The next scheduled time to
check the job.
state_name: str. The name of the state for which the classifier will be
generated.
status: str. The status of the training job request. This can be either
NEW (default), PENDING (when a job has been picked up) or COMPLETE.
training_data: list(dict). The training data that is used for training
the classifier. This is populated lazily when the job request is
picked up by the VM. The list contains dicts where each dict
represents a single training data group, for example:
training_data = [
{
'answer_group_index': 1,
'answers': ['a1', 'a2']
},
{
'answer_group_index': 2,
'answers': ['a2', 'a3']
}
]
classifier_data: dict. The actual classifier model used for
classification purpose.
data_schema_version: int. Schema version of the data used by the
classifier. This depends on the algorithm ID.
job_id: str. The unique id of the classifier training job.
algorithm_id: str. The id of the algorithm that will be used for
generating the classifier.
interaction_id: str. The id of the interaction to which the
algorithm belongs.
exp_id: str. The id of the exploration id that contains the state
for which classifier will be generated.
exp_version: int. The version of the exploration when
the training job was generated.
next_scheduled_check_time: datetime.datetime. The next scheduled
time to check the job.
state_name: str. The name of the state for which the classifier
will be generated.
status: str. The status of the training job request. This can
be either NEW (default), PENDING (when a job has been
picked up) or COMPLETE.
training_data: list(dict). The training data that is used
for training the classifier. This is populated lazily
when the job request is picked up by the VM. The list
contains dicts where each dict represents a single
training data group, for example:
training_data = [
{
'answer_group_index': 1,
'answers': ['a1', 'a2']
},
{
'answer_group_index': 2,
'answers': ['a2', 'a3']
}
]
classifier_data: dict. The actual classifier model used for
classification purpose.
data_schema_version: int. Schema version of the data used by the
classifier. This depends on the algorithm ID.
"""
self._job_id = job_id
self._algorithm_id = algorithm_id
Expand Down Expand Up @@ -475,7 +477,7 @@ def to_dict(self):
Returns:
A dict representation of TrainingJobExplorationMapping domain
object.
object.
"""

return {
Expand Down
12 changes: 6 additions & 6 deletions core/domain/classifier_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def handle_non_retrainable_states(exploration, state_names, exp_versions_diff):
Returns:
list(str). State names which don't have classifier model for previous
version of exploration.
version of exploration.
"""
exp_id = exploration.id
current_exp_version = exploration.version
Expand Down Expand Up @@ -182,11 +182,11 @@ 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
float values converted back from string to float.
float values converted back from string to float.
"""
if isinstance(classifier_data_with_floats_stringified, dict):
classifier_data = {}
Expand Down Expand Up @@ -227,7 +227,7 @@ def get_classifier_training_job_from_model(classifier_training_job_model):
Returns:
classifier_training_job: ClassifierTrainingJob. Domain object for the
classifier training job.
classifier training job.
"""
classifier_data = fs_services.read_classifier_data(
classifier_training_job_model.exp_id, classifier_training_job_model.id)
Expand All @@ -253,7 +253,7 @@ def get_classifier_training_job_by_id(job_id):
Returns:
classifier_training_job: ClassifierTrainingJob. Domain object for the
classifier training job.
classifier training job.
Raises:
Exception: Entity for class ClassifierTrainingJobModel with id not
Expand Down Expand Up @@ -434,7 +434,7 @@ def get_classifier_training_jobs(exp_id, exp_version, state_names):
Returns:
list(ClassifierTrainingJob). Domain objects for the Classifier training
job model.
job model.
"""
training_job_exploration_mapping_models = (
classifier_models.TrainingJobExplorationMappingModel.get_models(
Expand Down
18 changes: 9 additions & 9 deletions core/domain/collection_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def validate(self):
Raises:
ValidationError: One or more attributes of the collection node are
invalid.
invalid.
"""
if not isinstance(self.exploration_id, python_utils.BASESTRING):
raise utils.ValidationError(
Expand Down Expand Up @@ -452,11 +452,11 @@ def _migrate_to_latest_yaml_version(cls, yaml_content):
Returns:
str. The YAML representation of the collection, in the latest
schema format.
schema format.
Raises:
Exception: 'yaml_content' or the collection schema version is not
valid.
valid.
"""
try:
collection_dict = utils.dict_from_yaml(yaml_content)
Expand Down Expand Up @@ -638,7 +638,7 @@ def update_collection_contents_from_model(
Raises:
Exception: The value of the key 'schema_version' in
versioned_collection_contents is not valid.
versioned_collection_contents is not valid.
"""
if (versioned_collection_contents['schema_version'] + 1 >
feconf.CURRENT_COLLECTION_SCHEMA_VERSION):
Expand Down Expand Up @@ -673,8 +673,8 @@ def first_exploration_id(self):
the collection is empty, returns None.
Returns:
str|None. The exploration ID of the first node,
or None if the collection is empty.
str|None. The exploration ID of the first node, or None if the
collection is empty.
"""
if len(self.nodes) > 0:
return self.nodes[0].exploration_id
Expand All @@ -692,7 +692,7 @@ def get_next_exploration_id(self, completed_exp_ids):
Returns:
str|None. The exploration ID of the next node,
or None if the collection is completed.
or None if the collection is completed.
"""
for exp_id in self.exploration_ids:
if exp_id not in completed_exp_ids:
Expand All @@ -710,7 +710,7 @@ def get_next_exploration_id_in_sequence(self, current_exploration_id):
Returns:
str|None. The exploration ID of the next node,
or None if the passed id is the last one in the collection.
or None if the passed id is the last one in the collection.
"""
exploration_just_unlocked = None

Expand Down Expand Up @@ -870,7 +870,7 @@ def validate(self, strict=True):
Raises:
ValidationError: One or more attributes of the Collection are not
valid.
valid.
"""

# NOTE TO DEVELOPERS: Please ensure that this validation logic is the
Expand Down
13 changes: 6 additions & 7 deletions core/domain/collection_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _migrate_collection_contents_to_latest_schema(
Raises:
Exception: The schema version of the collection is outside of what is
supported at present.
supported at present.
"""
collection_schema_version = versioned_collection_contents['schema_version']
if not (1 <= collection_schema_version
Expand Down Expand Up @@ -408,7 +408,7 @@ def get_explorations_completed_in_collections(user_id, collection_ids):
Returns:
list(list(str)). List of the exploration ids completed in each
collection.
collection.
"""
progress_models = user_models.CollectionProgressModel.get_multi(
user_id, collection_ids)
Expand Down Expand Up @@ -561,7 +561,7 @@ def get_collection_ids_matching_query(query_string, cursor=None):
collections, to start the search from.
Returns:
2-tuple of (returned_collection_ids, search_cursor), where:
2-tuple of (returned_collection_ids, search_cursor). Where:
returned_collection_ids : list(str). A list with all collection ids
matching the given search query string, as well as a search
cursor for future fetches. The list contains exactly
Expand Down Expand Up @@ -604,12 +604,11 @@ def apply_change_list(collection_id, change_list):
Args:
collection_id: str. ID of the given collection.
change_list: list(dict). A change list to be applied to the given
collection. Each entry is a dict that represents a
CollectionChange.
object.
collection. Each entry is a dict that represents a CollectionChange
object.
Returns:
Collection. The resulting collection domain object.
Collection. The resulting collection domain object.
"""
collection = get_collection_by_id(collection_id)
try:
Expand Down
4 changes: 2 additions & 2 deletions core/domain/cron_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_stuck_jobs(recency_msecs):
Returns:
list(job_models.JobModel). Jobs which have retried at least once and
haven't finished yet.
haven't finished yet.
"""
threshold_time = (
datetime.datetime.utcnow() -
Expand Down Expand Up @@ -77,7 +77,7 @@ def map(item):
A shard or job which may still be running.
Yields:
tuple(str, int). Describes the action taken for the item, and the
number of items this action was applied to.
number of items this action was applied to.
"""
max_start_time_msec = JobCleanupManager.get_mapper_param(
jobs.MAPPER_PARAM_MAX_START_TIME_MSEC)
Expand Down
2 changes: 1 addition & 1 deletion core/domain/draft_upgrade_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def try_upgrading_draft_to_exp_version(
Returns:
list(ExplorationChange) or None. A list of ExplorationChange domain
objects after upgrade or None if upgrade fails.
objects after upgrade or None if upgrade fails.
Raises:
InvalidInputException. current_draft_version is greater than
Expand Down
2 changes: 1 addition & 1 deletion core/domain/email_jobs_one_off_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _generate_hash_for_tests(
Returns:
str. Empty if recipient_id is 'recipient_id2', None if
'recipient_id1' and 'Email Hash' otherwise.
'recipient_id1' and 'Email Hash' otherwise.
"""

if recipient_id == 'recipient_id1':
Expand Down
4 changes: 2 additions & 2 deletions core/domain/email_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ def get_moderator_unpublish_exploration_email():
Returns:
str. Draft of the email body for an email sent after the moderator
unpublishes an exploration, or an empty string if no email should
be sent.
unpublishes an exploration, or an empty string if no email should
be sent.
"""

try:
Expand Down
Loading

0 comments on commit 0d5e34d

Please sign in to comment.