diff --git a/constants.py b/constants.py index 5bcf92c954e4..d644ab0afee7 100644 --- a/constants.py +++ b/constants.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -#pylint: disable=invalid-name +# pylint: disable=invalid-name """Loads constants for backend use.""" diff --git a/core/controllers/base_test.py b/core/controllers/base_test.py index 26bf196804d7..7bcbea644442 100644 --- a/core/controllers/base_test.py +++ b/core/controllers/base_test.py @@ -141,7 +141,7 @@ def test_root_redirect_rules_for_logged_in_learners(self): def test_root_redirect_rules_for_users_with_no_user_contribution_model( self): self.login(self.TEST_LEARNER_EMAIL) - # delete the UserContributionModel. + # Delete the UserContributionModel. user_id = user_services.get_user_id_from_username( self.TEST_LEARNER_USERNAME) user_contribution_model = user_models.UserContributionsModel.get( diff --git a/core/controllers/editor_test.py b/core/controllers/editor_test.py index 0e22eb37e7e6..058fcda815c5 100644 --- a/core/controllers/editor_test.py +++ b/core/controllers/editor_test.py @@ -1883,7 +1883,7 @@ def test_draft_not_updated_validation_error(self): '%s.%s' % (self.owner_id, self.EXP_ID2)) self.assertEqual( exp_user_data.draft_change_list, self.DRAFT_CHANGELIST) - # id is incremented the first time but not the second. + # ID is incremented the first time but not the second. self.assertEqual(exp_user_data.draft_change_list_id, 2) self.assertEqual( response, {'status_code': 400, diff --git a/core/controllers/library_test.py b/core/controllers/library_test.py index 3fadb4ab69d7..d4ddb93f233f 100644 --- a/core/controllers/library_test.py +++ b/core/controllers/library_test.py @@ -94,7 +94,7 @@ def test_library_handler_demo_exploration(self): self.count_jobs_in_taskqueue( taskqueue_services.QUEUE_NAME_ONE_OFF_JOBS), 0) - # change title and category. + # Change title and category. exp_services.update_exploration( self.editor_id, '0', [exp_domain.ExplorationChange({ 'cmd': 'edit_exploration_property', diff --git a/core/domain/email_manager_test.py b/core/domain/email_manager_test.py index 88e444154c0c..2f0a3f67d2e4 100644 --- a/core/domain/email_manager_test.py +++ b/core/domain/email_manager_test.py @@ -1213,7 +1213,7 @@ def test_correct_email_body_is_sent(self): email_manager.send_feedback_message_email( self.editor_id, feedback_messages) - # check that email body is correct. + # Check that email body is correct. messages = self.mail_stub.get_sent_messages(to=self.EDITOR_EMAIL) self.assertEqual(len(messages), 1) self.assertEqual( @@ -1223,7 +1223,7 @@ def test_correct_email_body_is_sent(self): messages[0].body.decode(), expected_email_text_body) - # check that email model is correct. + # Check that email model is correct. all_models = email_models.SentEmailModel.get_all().fetch() self.assertEqual(len(all_models), 1) @@ -1299,7 +1299,7 @@ def test_that_suggestion_emails_are_correct(self): self.exploration.title, self.exploration.id, self.new_user_id, self.recipient_list) - # make sure correct email is sent. + # Make sure correct email is sent. messages = self.mail_stub.get_sent_messages(to=self.EDITOR_EMAIL) self.assertEqual(len(messages), 1) self.assertEqual( @@ -1382,7 +1382,7 @@ def test_that_subscription_emails_are_correct(self): email_manager.send_emails_to_subscribers( self.editor_id, self.exploration.id, self.exploration.title) - # make sure correct email is sent. + # Make sure correct email is sent. messages = self.mail_stub.get_sent_messages(to=self.NEW_USER_EMAIL) self.assertEqual(len(messages), 1) self.assertEqual( diff --git a/core/domain/email_subscription_services_test.py b/core/domain/email_subscription_services_test.py index 98b3751668de..df91d03e645c 100644 --- a/core/domain/email_subscription_services_test.py +++ b/core/domain/email_subscription_services_test.py @@ -78,7 +78,7 @@ def test_inform_subscribers(self): email_subscription_services.inform_subscribers( self.editor_id, 'A', 'Title') - # make sure correct number of emails is sent and no email is sent + # Make sure correct number of emails is sent and no email is sent # to the person who has unsubscribed from subscription emails. messages = self.mail_stub.get_sent_messages(to=self.NEW_USER_EMAIL) self.assertEqual(len(messages), 1) diff --git a/core/domain/exp_domain.py b/core/domain/exp_domain.py index cb12df0aa401..b6fe185be4d5 100644 --- a/core/domain/exp_domain.py +++ b/core/domain/exp_domain.py @@ -1308,7 +1308,7 @@ def _convert_states_v0_dict_to_v1_dict(cls, states_dict): Returns: dict. The converted states_dict. """ - # ensure widgets are renamed to be interactions. + # Ensure widgets are renamed to be interactions. for _, state_defn in states_dict.iteritems(): if 'widget' not in state_defn: continue diff --git a/core/domain/exp_services_test.py b/core/domain/exp_services_test.py index 01ac2d68194b..c09973a43a9f 100644 --- a/core/domain/exp_services_test.py +++ b/core/domain/exp_services_test.py @@ -2500,7 +2500,7 @@ def test_get_next_page_of_all_non_private_commits(self): self.assertDictContainsSubset( self.COMMIT_ALBERT_PUBLISH_EXP_2, commit_dicts[0]) - #TODO(frederikcreemers@gmail.com) test max_age here. + # TODO(frederikcreemers@gmail.com) test max_age here. class ExplorationSearchTests(ExplorationServicesUnitTests): @@ -2829,7 +2829,7 @@ def test_get_non_private_exploration_summaries(self): actual_summaries[self.EXP_ID_2].first_published_msec )} - # check actual summaries equal expected summaries. + # Check actual summaries equal expected summaries. self.assertEqual(actual_summaries.keys(), expected_summaries.keys()) simple_props = ['id', 'title', 'category', 'objective', @@ -2873,7 +2873,7 @@ def test_get_all_exploration_summaries(self): ) } - # check actual summaries equal expected summaries. + # Check actual summaries equal expected summaries. self.assertEqual(actual_summaries.keys(), expected_summaries.keys()) simple_props = ['id', 'title', 'category', 'objective', diff --git a/core/domain/feedback_services.py b/core/domain/feedback_services.py index 54da9b76921a..697f94921239 100644 --- a/core/domain/feedback_services.py +++ b/core/domain/feedback_services.py @@ -201,7 +201,7 @@ def create_message( if (user_services.is_user_registered(author_id) and feconf.CAN_SEND_EMAILS and feconf.CAN_SEND_FEEDBACK_MESSAGE_EMAILS): - # send feedback message email if user is registered. + # Send feedback message email if user is registered. _add_message_to_email_buffer( author_id, thread_id, message_id, len(text), old_status, new_status) diff --git a/core/domain/html_validation_service.py b/core/domain/html_validation_service.py index 3ad722ac71e2..ebb34bae515a 100644 --- a/core/domain/html_validation_service.py +++ b/core/domain/html_validation_service.py @@ -161,7 +161,7 @@ def convert_to_textangular(html_data): feconf.RTE_CONTENT_SPEC[ 'RTE_TYPE_TEXTANGULAR']['ALLOWED_PARENT_LIST']) - # td tag will be unwrapped and tr tag will be replaced with p tag. + # The td tag will be unwrapped and tr tag will be replaced with p tag. # So if td is parent of blockquote after migration blockquote should # be parent of the p tag to get the alomst same appearance. p cannot # remain parent of blockquote since that is not allowed in TextAngular. @@ -194,7 +194,7 @@ def convert_to_textangular(html_data): # the same appearance. elif tag.name == 'hr': tag.name = 'br' - # a tag is to be replaced with oppia-noninteractive-link. + # 'a' tag is to be replaced with oppia-noninteractive-link. # For this the attributes and text within a tag is used to # create new link tag which is wrapped as parent of a and then # a tag is removed. @@ -238,8 +238,8 @@ def convert_to_textangular(html_data): elif tag.name == 'td' and tag.next_sibling: tag.insert_after(' ') tag.unwrap() - # div and table rows both are replaced with p tag - # to maintain almost same apperance. + # Divs and table rows are both replaced with p tag + # to maintain almost same appearance. elif tag.name == 'div' or tag.name == 'tr': tag.name = 'p' # All other invalid tags are simply removed. diff --git a/core/domain/rights_manager_test.py b/core/domain/rights_manager_test.py index 6983dcd2540b..112123453cba 100644 --- a/core/domain/rights_manager_test.py +++ b/core/domain/rights_manager_test.py @@ -437,7 +437,7 @@ def test_check_exploration_rights(self): def test_get_multiple_exploration_rights(self): exp_ids = ['exp1', 'exp2', 'exp3', 'exp4'] - # saving only first 3 explorations to check that None is returned for + # Saving only first 3 explorations to check that None is returned for # non-existing exploration. for exp_id in exp_ids[:3]: self.save_new_valid_exploration(exp_id, self.user_id_admin) diff --git a/core/domain/stats_jobs_continuous_test.py b/core/domain/stats_jobs_continuous_test.py index 059d124d08a5..b046f25e9757 100644 --- a/core/domain/stats_jobs_continuous_test.py +++ b/core/domain/stats_jobs_continuous_test.py @@ -81,7 +81,7 @@ def test_one_answer(self): jobs_registry, 'ALL_CONTINUOUS_COMPUTATION_MANAGERS', self.ALL_CC_MANAGERS_FOR_TESTS): - # setup example exploration. + # Setup example exploration. exp_id = 'eid' exp = self.save_new_valid_exploration(exp_id, 'fake@user.com') first_state_name = exp.init_state_name @@ -113,7 +113,7 @@ def test_one_answer(self): exp_id, exp_version, first_state_name, 'session2') self.process_and_flush_pending_tasks() - # add some answers. + # Add some answers. event_services.AnswerSubmissionEventHandler.record( exp_id, exp_version, first_state_name, 'MultipleChoiceInput', 0, 0, exp_domain.EXPLICIT_CLASSIFICATION, 'session1', time_spent, @@ -143,7 +143,7 @@ def test_one_answer(self): calc_id = 'AnswerFrequencies' - # get job output of first state and check it. + # Get job output of first state and check it. calc_output_model = self._get_calc_output_model( exp_id, first_state_name, calc_id, exploration_version=exp_version) @@ -162,7 +162,7 @@ def test_one_answer(self): self.assertEqual(calculation_output, expected_calculation_output) - # get job output of second state and check it. + # Get job output of second state and check it. calc_output_model = self._get_calc_output_model( exp_id, second_state_name, calc_id, exploration_version=exp_version) @@ -184,7 +184,7 @@ def test_one_answer_ignored_for_deleted_exploration(self): jobs_registry, 'ALL_CONTINUOUS_COMPUTATION_MANAGERS', self.ALL_CC_MANAGERS_FOR_TESTS): - # setup example exploration. + # Setup example exploration. exp_id = 'eid' exp = self.save_new_valid_exploration(exp_id, 'fake@user.com') first_state_name = exp.init_state_name @@ -712,7 +712,7 @@ def test_multiple_computations_in_one_job(self): jobs_registry, 'ALL_CONTINUOUS_COMPUTATION_MANAGERS', self.ALL_CC_MANAGERS_FOR_TESTS): - # setup example exploration. + # Setup example exploration. exp_id = 'eid' exp = self.save_new_valid_exploration(exp_id, 'fake@user.com') first_state_name = exp.init_state_name diff --git a/core/domain/stats_jobs_one_off.py b/core/domain/stats_jobs_one_off.py index ce969536c926..e35a8606b2f0 100644 --- a/core/domain/stats_jobs_one_off.py +++ b/core/domain/stats_jobs_one_off.py @@ -161,7 +161,7 @@ def map(exploration_model): old_state_name = ( exp_versions_diff.new_to_old_state_names[ state_name]) - # pssm is previous state stats mapping. + # 'pssm' mean 'previous state stats mapping'. pssm = prev_exp_stats.state_stats_mapping[ old_state_name] exp_stats_default.state_stats_mapping[ diff --git a/core/domain/stats_services_test.py b/core/domain/stats_services_test.py index 13fdbb348490..2cf7c0e639fe 100644 --- a/core/domain/stats_services_test.py +++ b/core/domain/stats_services_test.py @@ -1010,7 +1010,7 @@ def test_record_answer(self): 'eid', exp_version, state_name) self.assertEqual(state_answers, None) - # answer is a string. + # Answer is a string. event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, first_state_name, 'TextInput', 0, 0, exp_domain.EXPLICIT_CLASSIFICATION, 'sid1', self.TIME_SPENT, @@ -1019,32 +1019,32 @@ def test_record_answer(self): 'eid', exp_version, first_state_name, 'TextInput', 0, 1, exp_domain.EXPLICIT_CLASSIFICATION, 'sid2', self.TIME_SPENT, self.PARAMS, 'answer1') - # answer is a dict. + # Answer is a dict. event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, first_state_name, 'TextInput', 1, 0, exp_domain.EXPLICIT_CLASSIFICATION, 'sid1', self.TIME_SPENT, self.PARAMS, {'x': 1.0, 'y': 5.0}) - # answer is a number. + # Answer is a number. event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, first_state_name, 'TextInput', 2, 0, exp_domain.EXPLICIT_CLASSIFICATION, 'sid1', self.TIME_SPENT, self.PARAMS, 10) - # answer is a list of dicts. + # Answer is a list of dicts. event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, first_state_name, 'TextInput', 3, 0, exp_domain.EXPLICIT_CLASSIFICATION, 'sid1', self.TIME_SPENT, self.PARAMS, [{'a': 'some', 'b': 'text'}, {'a': 1.0, 'c': 2.0}]) - # answer is a list. + # Answer is a list. event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, second_state_name, 'TextInput', 2, 0, exp_domain.EXPLICIT_CLASSIFICATION, 'sid3', self.TIME_SPENT, self.PARAMS, [2, 4, 8]) - # answer is a unicode string. + # Answer is a unicode string. event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, second_state_name, 'TextInput', 1, 1, exp_domain.EXPLICIT_CLASSIFICATION, 'sid4', self.TIME_SPENT, self.PARAMS, self.UNICODE_TEST_STRING) - # answer is None (such as for Continue). + # Answer is None (such as for Continue). event_services.AnswerSubmissionEventHandler.record( 'eid', exp_version, third_state_name, 'Continue', 1, 1, exp_domain.EXPLICIT_CLASSIFICATION, 'sid5', self.TIME_SPENT, diff --git a/core/domain/user_jobs_continuous.py b/core/domain/user_jobs_continuous.py index cb4f292a6d6b..5fa53a98bb44 100644 --- a/core/domain/user_jobs_continuous.py +++ b/core/domain/user_jobs_continuous.py @@ -599,7 +599,7 @@ def map(item): value_per_user * reach * contribution) }) - # if the user is an owner for the exploration, then update dict with + # If the user is an owner for the exploration, then update dict with # 'average ratings' and 'total plays' as well. if contrib_id in exploration_summary.owner_ids: mapped_owner_ids.append(contrib_id) diff --git a/core/domain/user_jobs_one_off_test.py b/core/domain/user_jobs_one_off_test.py index 8b42b9f3af10..aa72f0230010 100644 --- a/core/domain/user_jobs_one_off_test.py +++ b/core/domain/user_jobs_one_off_test.py @@ -236,7 +236,7 @@ def test_null_case(self): default user having the username - 'tmpsuperadm1n'. """ output = self._run_one_off_job() - # number of users = 1. + # Number of users = 1. # length of usernames = 13 (tmpsuperadm1n). self.assertEqual(output['13'], 1) @@ -246,7 +246,7 @@ def test_single_user_case(self): """ self.signup(self.USER_A_EMAIL, self.USER_A_USERNAME) output = self._run_one_off_job() - # number of users = 2. + # Number of users = 2. # length of usernames = 13 (tmpsuperadm1n), 1 (a). self.assertEqual(output['13'], 1) self.assertEqual(output['1'], 1) @@ -258,7 +258,7 @@ def test_multiple_users_case(self): self.signup(self.USER_A_EMAIL, self.USER_A_USERNAME) self.signup(self.USER_B_EMAIL, self.USER_B_USERNAME) output = self._run_one_off_job() - # number of users = 3 + # Number of users = 3 # length of usernames = 13 (tmpsuperadm1n), 2 (ab), 1 (a). self.assertEqual(output['13'], 1) self.assertEqual(output['2'], 1) @@ -267,7 +267,7 @@ def test_multiple_users_case(self): self.signup(self.USER_C_EMAIL, self.USER_C_USERNAME) self.signup(self.USER_D_EMAIL, self.USER_D_USERNAME) output = self._run_one_off_job() - # number of users = 5 + # Number of users = 5 # length of usernames = 13 (tmpsuperadm1n), 3 (bcd), 2 (ab, bc), 1 (a). self.assertEqual(output['13'], 1) self.assertEqual(output['3'], 1) diff --git a/core/platform/search/gae_search_services_test.py b/core/platform/search/gae_search_services_test.py index b23704eeadcf..9a53e42f5c7b 100644 --- a/core/platform/search/gae_search_services_test.py +++ b/core/platform/search/gae_search_services_test.py @@ -258,7 +258,7 @@ def test_put_error_without_transient_result(self): with add_docs_ctx, put_ctx, assert_raises_ctx as e: gae_search_services.add_documents_to_index(docs, 'my_index') - # assert that the method only gets called once, since the error is not + # Assert that the method only gets called once, since the error is not # transient. self.assertEqual(add_docs_counter.times_called, 1) self.assertEqual(e.exception.original_exception, error) @@ -432,7 +432,7 @@ def test_put_error_without_transient_result(self): ['a', 'b', 'c'], 'my_index') - # assert that the method only gets called once, since the error is not + # Assert that the method only gets called once, since the error is not # transient. self.assertEqual(delete_docs_counter.times_called, 1) self.assertEqual(e.exception.original_exception, error) @@ -689,7 +689,7 @@ def test_arguments_are_preserved_in_retries(self): self.assertEqual(search_counter.times_called, 4) self.assertEqual(result, ['doc2', 'doc1']) - # also check that the cursor is preserved. + # Also check that the cursor is preserved. self.assertEqual(search_counter2.times_called, 4) self.assertEqual(result2, ['doc0']) diff --git a/core/storage/statistics/gae_models.py b/core/storage/statistics/gae_models.py index 03b94d7390e7..1868697983b2 100644 --- a/core/storage/statistics/gae_models.py +++ b/core/storage/statistics/gae_models.py @@ -1596,7 +1596,7 @@ def create_or_update( exploration_id, exploration_version, state_name, calculation_id) instance = cls.get(instance_id, strict=False) if not instance: - # create new instance. + # Create new instance. instance = cls( id=instance_id, exploration_id=exploration_id, exploration_version=exploration_version, diff --git a/scripts/build_test.py b/scripts/build_test.py index bd05cd1a5fdf..c846009def62 100644 --- a/scripts/build_test.py +++ b/scripts/build_test.py @@ -61,7 +61,7 @@ def test_minify(self): """Tests _minify with an invalid filepath.""" with self.assertRaises(subprocess.CalledProcessError) as called_process: build._minify(INVALID_INPUT_FILEPATH, INVALID_OUTPUT_FILEPATH) - # returncode is the exit status of the child process. + # `returncode` is the exit status of the child process. self.assertEqual(called_process.exception.returncode, 1) def test_minify_and_create_sourcemap(self): @@ -69,7 +69,7 @@ def test_minify_and_create_sourcemap(self): with self.assertRaises(subprocess.CalledProcessError) as called_process: build._minify_and_create_sourcemap( INVALID_INPUT_FILEPATH, INVALID_OUTPUT_FILEPATH) - # returncode is the exit status of the child process. + # `returncode` is the exit status of the child process. self.assertEqual(called_process.exception.returncode, 1) def test_ensure_files_exist(self): @@ -421,7 +421,7 @@ def test_get_hashes_json_file_contents(self): """Test get_hashes_json_file_contents parses provided hash dict correctly to JSON format. """ - # set constant to provide everything to frontend. + # Set constant to provide everything to frontend. with self.swap(build, 'FILEPATHS_PROVIDED_TO_FRONTEND', ('*',)): hashes = {'path/file.js': '123456'} self.assertEqual( diff --git a/scripts/install_third_party.py b/scripts/install_third_party.py index 9cf4f585d5f8..8f74184041f7 100644 --- a/scripts/install_third_party.py +++ b/scripts/install_third_party.py @@ -27,8 +27,8 @@ import common # pylint: disable=relative-import -#These two lines prevent a "IOError: [Errno socket error] -#[Errno -2] Name or service not known" error +# These two lines prevent a "IOError: [Errno socket error] +# [Errno -2] Name or service not known" error # in urllib.urlretrieve, if the user is behind a proxy. if 'VAGRANT' in os.environ: os.environ['http_proxy'] = '' diff --git a/scripts/pre_commit_linter.py b/scripts/pre_commit_linter.py index d4e725abd8a6..065dc9b0ac2a 100644 --- a/scripts/pre_commit_linter.py +++ b/scripts/pre_commit_linter.py @@ -947,7 +947,7 @@ def _check_import_order(all_files): def _check_comments(all_files): - """This function ensures that comments end in a period.""" + """This function ensures that comments follow correct style.""" print 'Starting comment checks' print '----------------------------------------' summary_messages = [] @@ -957,6 +957,8 @@ def _check_comments(all_files): and filename.endswith('.py')] message = 'There should be a period at the end of the comment.' failed = False + space_regex = re.compile(r'^#[^\s].*$') + capital_regex = re.compile('^# [a-z][A-Za-z]* .*$') for filename in files_to_check: with open(filename, 'r') as f: file_content = f.readlines() @@ -964,8 +966,11 @@ def _check_comments(all_files): for line_num in range(file_length): line = file_content[line_num].lstrip().rstrip() next_line = '' + previous_line = '' if line_num + 1 < file_length: next_line = file_content[line_num + 1].lstrip().rstrip() + if line_num > 0: + previous_line = file_content[line_num - 1].lstrip().rstrip() if line.startswith('#') and not next_line.startswith('#'): # Check that the comment ends with the proper punctuation. @@ -979,6 +984,26 @@ def _check_comments(all_files): print '%s --> Line %s: %s' % ( filename, line_num + 1, message) + # Check that comment starts with a space and is not a shebang + # expression at the start of a bash script which loses function + # when a space is added. + if space_regex.match(line) and not line.startswith('#!'): + message = ( + 'There should be a space at the beginning ' + 'of the comment.') + failed = True + print '%s --> Line %s: %s' % ( + filename, line_num + 1, message) + + # Check that comment starts with a capital letter. + if not previous_line.startswith('#') and ( + capital_regex.match(line)): + message = ( + 'There should be a capital letter' + ' to begin the content of the comment.') + failed = True + print '%s --> Line %s: %s' % ( + filename, line_num + 1, message) print '' print '----------------------------------------' diff --git a/scripts/pre_push_hook.py b/scripts/pre_push_hook.py index 6a119b146898..34d0f79da416 100755 --- a/scripts/pre_push_hook.py +++ b/scripts/pre_push_hook.py @@ -44,7 +44,7 @@ 'GitRef', ['local_ref', 'local_sha1', 'remote_ref', 'remote_sha1']) FileDiff = collections.namedtuple('FileDiff', ['status', 'name']) -# git hash of /dev/null, refers to an 'empty' commit. +# Git hash of /dev/null, refers to an 'empty' commit. GIT_NULL_COMMIT = '4b825dc642cb6eb9a060e54bf8d69288fbee4904' # caution, __file__ is here *OPPiA/.git/hooks* and not in *OPPIA/scripts*. @@ -168,18 +168,18 @@ def _collect_files_being_pushed(ref_list, remote): """ if not ref_list: return {} - # avoid testing of non branch pushes (tags for instance) or deletions. + # Avoid testing of non branch pushes (tags for instance) or deletions. ref_heads_only = [ref for ref in ref_list if ref.local_ref.startswith('refs/heads/')] - # get branch name from e.g. local_ref='refs/heads/lint_hook'. + # Get branch name from e.g. local_ref='refs/heads/lint_hook'. branches = [ref.local_ref.split('/')[-1] for ref in ref_heads_only] hashes = [ref.local_sha1 for ref in ref_heads_only] remote_hashes = [ref.remote_sha1 for ref in ref_heads_only] collected_files = {} - # git allows that multiple branches get pushed simultaneously with the "all" + # Git allows that multiple branches get pushed simultaneously with the "all" # flag. Therefore we need to loop over the ref_list provided. for branch, sha1, remote_sha1 in zip(branches, hashes, remote_hashes): - # git reports the following for an empty / non existing branch + # Git reports the following for an empty / non existing branch # sha1: '0000000000000000000000000000000000000000'. if set(remote_sha1) != {'0'}: try: @@ -193,7 +193,7 @@ def _collect_files_being_pushed(ref_list, remote): modified_files = _compare_to_remote( remote, branch, remote_branch='develop') except ValueError: - # give up, return all files in repo. + # Give up, return all files in repo. try: modified_files = _git_diff_name_status( GIT_NULL_COMMIT, sha1) @@ -245,7 +245,7 @@ def _has_uncommitted_files(): def _install_hook(): - # install script ensures that oppia is root. + # Install script ensures that oppia is root. oppia_dir = os.getcwd() hooks_dir = os.path.join(oppia_dir, '.git', 'hooks') pre_push_file = os.path.join(hooks_dir, 'pre-push') @@ -255,7 +255,7 @@ def _install_hook(): try: os.symlink(os.path.abspath(__file__), pre_push_file) print 'Created symlink in .git/hooks directory' - # raises AttributeError on windows, OSError added as failsafe. + # Raises AttributeError on windows, OSError added as failsafe. except (OSError, AttributeError): shutil.copy(__file__, pre_push_file) print 'Copied file to .git/hooks directory' @@ -277,7 +277,7 @@ def main(): sys.exit(0) refs = _get_refs() collected_files = _collect_files_being_pushed(refs, remote) - # only interfere if we actually have something to lint (prevent annoyances). + # Only interfere if we actually have something to lint (prevent annoyances). if collected_files and _has_uncommitted_files(): print ('Your repo is in a dirty state which prevents the linting from' ' working.\nStash your changes or commit them.\n') diff --git a/scripts/pylint_extensions.py b/scripts/pylint_extensions.py index 9103528e9daf..ad0a6aa8046d 100644 --- a/scripts/pylint_extensions.py +++ b/scripts/pylint_extensions.py @@ -243,7 +243,7 @@ class DocstringParameterChecker(checkers.BaseChecker): 'W9012': ('Missing return type documentation', 'missing-return-type-doc', 'Please document the type returned by this method.', - # we can't use the same old_name for two different warnings + # We can't use the same old_name for two different warnings # {'old_names': [('W9007', 'missing-returns-doc')]}. ), 'W9013': ('Missing yield documentation', @@ -253,7 +253,7 @@ class DocstringParameterChecker(checkers.BaseChecker): 'W9014': ('Missing yield type documentation', 'missing-yield-type-doc', 'Please document the type yielded by this method.', - # we can't use the same old_name for two different warnings + # We can't use the same old_name for two different warnings # {'old_names': [('W9009', 'missing-yields-doc')]}. ), 'W9015': ('"%s" missing in parameter documentation',