fix: enable pylint warnings (#36196)
This commit is contained in:
@@ -995,9 +995,9 @@ def get_course_youtube_edx_video_ids(course_id):
|
||||
f"InvalidKeyError occurred while getting YouTube video IDs for course_id: {course_id}: {error}"
|
||||
)
|
||||
return JsonResponse({'error': invalid_key_error_msg}, status=500)
|
||||
except Exception as error:
|
||||
except (TypeError, AttributeError) as error:
|
||||
LOGGER.exception(
|
||||
f"Unexpected error occurred while getting YouTube video IDs for course_id: {course_id}: {error}"
|
||||
f"Error occurred while getting YouTube video IDs for course_id: {course_id}: {error}"
|
||||
)
|
||||
return JsonResponse({'error': unexpected_error_msg}, status=500)
|
||||
|
||||
|
||||
@@ -1028,7 +1028,7 @@ class LoginFailures(models.Model):
|
||||
entry = cls._get_record_for_user(user)
|
||||
entry.delete()
|
||||
except ObjectDoesNotExist:
|
||||
return
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
"""Str -> Username: count - date."""
|
||||
|
||||
@@ -59,7 +59,7 @@ class ProfileParentalControlsTest(TestCase):
|
||||
self.set_year_of_birth(current_year - 13)
|
||||
assert self.profile.requires_parental_consent()
|
||||
assert self.profile.requires_parental_consent(year=current_year)
|
||||
assert not self.profile.requires_parental_consent(year=(current_year + 1))
|
||||
assert not self.profile.requires_parental_consent(year=current_year + 1)
|
||||
|
||||
# Verify for a child born 14 years ago
|
||||
self.set_year_of_birth(current_year - 14)
|
||||
|
||||
@@ -51,8 +51,8 @@ from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # l
|
||||
|
||||
TOMORROW = now() + timedelta(days=1)
|
||||
ONE_WEEK_AGO = now() - timedelta(weeks=1)
|
||||
THREE_YEARS_FROM_NOW = now() + timedelta(days=(365 * 3))
|
||||
THREE_YEARS_AGO = now() - timedelta(days=(365 * 3))
|
||||
THREE_YEARS_FROM_NOW = now() + timedelta(days=365 * 3)
|
||||
THREE_YEARS_AGO = now() - timedelta(days=365 * 3)
|
||||
|
||||
# Name of the method to mock for Content Type Gating.
|
||||
GATING_METHOD_NAME = 'openedx.features.content_type_gating.models.ContentTypeGatingConfig.enabled_for_enrollment'
|
||||
|
||||
@@ -60,7 +60,7 @@ class TpaAPITestCase(ThirdPartyAuthTestMixin, APITestCase):
|
||||
|
||||
# Create several users and link each user to Google and TestShib
|
||||
for username in LINKED_USERS:
|
||||
make_superuser = (username == ADMIN_USERNAME)
|
||||
make_superuser = username == ADMIN_USERNAME
|
||||
make_staff = (username == STAFF_USERNAME) or make_superuser
|
||||
user = UserFactory.create(
|
||||
username=username,
|
||||
|
||||
@@ -177,7 +177,7 @@ class LTIAuthBackend(BaseAuth):
|
||||
|
||||
# As this must take constant time, do not use shortcutting operators such as 'and'.
|
||||
# Instead, use constant time operators such as '&', which is the bitwise and.
|
||||
valid = (lti_consumer_valid)
|
||||
valid = lti_consumer_valid
|
||||
valid = valid & (submitted_signature == computed_signature)
|
||||
valid = valid & (request.oauth_version == '1.0')
|
||||
valid = valid & (request.oauth_signature_method == 'HMAC-SHA1')
|
||||
|
||||
@@ -114,7 +114,7 @@ class Target(models.Model):
|
||||
"""
|
||||
staff_qset = CourseStaffRole(course_id).users_with_role()
|
||||
instructor_qset = CourseInstructorRole(course_id).users_with_role()
|
||||
staff_instructor_qset = (staff_qset | instructor_qset)
|
||||
staff_instructor_qset = staff_qset | instructor_qset
|
||||
enrollment_query = models.Q(
|
||||
is_active=True,
|
||||
courseenrollment__course_id=course_id,
|
||||
|
||||
@@ -36,7 +36,7 @@ class VisibilityTransformerTestCase(BlockParentsMapTestCase):
|
||||
):
|
||||
for idx, _ in enumerate(self.parents_map):
|
||||
block = self.get_block(idx)
|
||||
block.visible_to_staff_only = (idx in staff_only_blocks)
|
||||
block.visible_to_staff_only = idx in staff_only_blocks
|
||||
update_block(block)
|
||||
|
||||
self.assert_transform_results(
|
||||
|
||||
@@ -224,8 +224,11 @@ class Command(BaseCommand):
|
||||
'goal_count': total_goals,
|
||||
}
|
||||
)
|
||||
log.info(f'Processing course goals, total goal count {total_goals},'
|
||||
+ f'timestamp: {datetime.now()}, uuid: {session_id}')
|
||||
log.info('Processing course goals, total goal count {}, timestamp: {}, uuid: {}'.format(
|
||||
total_goals,
|
||||
datetime.now(),
|
||||
session_id
|
||||
))
|
||||
for goal in course_goals:
|
||||
# emulate a request for waffle's benefit
|
||||
with emulate_http_request(site=Site.objects.get_current(), user=goal.user):
|
||||
@@ -234,8 +237,13 @@ class Command(BaseCommand):
|
||||
else:
|
||||
filtered_count += 1
|
||||
if (sent_count + filtered_count) % 10000 == 0:
|
||||
log.info(f'Processing course goals: sent {sent_count} filtered {filtered_count} out of {total_goals},'
|
||||
+ f'timestamp: {datetime.now()}, uuid: {session_id}')
|
||||
log.info('Processing course goals: sent {} filtered {} out of {}, timestamp: {}, uuid: {}'.format(
|
||||
sent_count,
|
||||
filtered_count,
|
||||
total_goals,
|
||||
datetime.now(),
|
||||
session_id
|
||||
))
|
||||
|
||||
tracker.emit(
|
||||
'edx.course.goal.email.session_completed',
|
||||
@@ -247,8 +255,10 @@ class Command(BaseCommand):
|
||||
'emails_filtered': filtered_count,
|
||||
}
|
||||
)
|
||||
log.info(f'Processing course goals complete: sent {sent_count} emails, filtered out {filtered_count} emails'
|
||||
+ f'timestamp: {datetime.now()}, uuid: {session_id}')
|
||||
log.info('Processing course goals complete: sent {} emails, '
|
||||
'filtered out {} emails, timestamp: {}, '
|
||||
'uuid: {}'.format(sent_count, filtered_count, datetime.now(), session_id)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def handle_goal(goal, today, sunday_date, monday_date, session_id):
|
||||
@@ -346,5 +356,5 @@ def send_email_using_ses(user, msg):
|
||||
|
||||
log.info(f"Goal Reminder Email: email sent using SES with message ID {response['MessageId']}")
|
||||
send_ace_message_sent_signal(DjangoEmailChannel, msg)
|
||||
except Exception as e:
|
||||
except Exception as e: # pylint: disable=broad-exception-caught
|
||||
log.error(f"Goal Reminder Email: Error sending email using SES: {e}")
|
||||
|
||||
@@ -617,7 +617,7 @@ class CourseDateSummaryTest(SharedModuleStoreTestCase):
|
||||
block = VerificationDeadlineDate(course, user)
|
||||
assert block.css_class == 'verification-deadline-passed'
|
||||
assert block.title == 'Missed Verification Deadline'
|
||||
assert block.date == (datetime.now(utc) + timedelta(days=(- 1)))
|
||||
assert block.date == (datetime.now(utc) + timedelta(days=- 1))
|
||||
assert block.description == "Unfortunately you missed this course's deadline for a successful verification."
|
||||
assert block.link_text == 'Learn More'
|
||||
assert block.link == ''
|
||||
|
||||
@@ -120,8 +120,6 @@ def send_ace_message(context): # lint-amnesty, pylint: disable=missing-function
|
||||
log.info('Sending forum comment notification with context %s', message_context)
|
||||
ace.send(message, limit_to_channels=[ChannelType.PUSH])
|
||||
_track_notification_sent(message, context)
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
@shared_task(base=LoggedTask)
|
||||
|
||||
@@ -514,7 +514,6 @@ class CreditRequirementStatus(TimeStampedModel):
|
||||
)
|
||||
)
|
||||
log.error(log_msg)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def retire_user(cls, retirement):
|
||||
|
||||
@@ -523,7 +523,7 @@ class UpdateAllNotificationPreferencesView(APIView):
|
||||
'error': f'Invalid path: {app}.notification_types.{notification_type}.{channel}'
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
except (KeyError, AttributeError, ValueError) as e:
|
||||
errors.append({
|
||||
'course_id': str(preference.course_id),
|
||||
'error': str(e)
|
||||
@@ -551,7 +551,7 @@ class UpdateAllNotificationPreferencesView(APIView):
|
||||
status=status.HTTP_200_OK if updated_courses else status.HTTP_400_BAD_REQUEST
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
except (KeyError, AttributeError, ValueError) as e:
|
||||
return Response({
|
||||
'status': 'error',
|
||||
'message': str(e)
|
||||
|
||||
7
pylintrc
7
pylintrc
@@ -317,10 +317,7 @@ disable =
|
||||
too-many-positional-arguments,
|
||||
possibly-used-before-assignment,
|
||||
use-dict-literal,
|
||||
useless-return,
|
||||
superfluous-parens,
|
||||
logging-not-lazy,
|
||||
broad-exception-caught,
|
||||
superfluous-parens
|
||||
|
||||
[REPORTS]
|
||||
output-format = text
|
||||
@@ -417,4 +414,4 @@ int-import-graph =
|
||||
[EXCEPTIONS]
|
||||
overgeneral-exceptions = builtins.Exception
|
||||
|
||||
# 85c3d025c367597a0a7b23a05fdde9d8c63e1374
|
||||
# 5aea7d7fb264005eb373099c856a54cdfa4f311c
|
||||
|
||||
@@ -36,10 +36,7 @@ disable+ =
|
||||
too-many-positional-arguments,
|
||||
possibly-used-before-assignment,
|
||||
use-dict-literal,
|
||||
useless-return,
|
||||
superfluous-parens,
|
||||
logging-not-lazy,
|
||||
broad-exception-caught,
|
||||
superfluous-parens
|
||||
|
||||
[BASIC]
|
||||
attr-rgx = [a-z_][a-z0-9_]{2,40}$
|
||||
|
||||
Reference in New Issue
Block a user