Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,5 @@ def handle(self, *args, **options):

if error_keys:
msg = 'The following courses encountered errors and were not updated:\n'
for error_key in error_keys:
msg += f' - {error_key}\n'
msg += '\n'.join(f' - {error_key}' for error_key in error_keys)
logger.info(msg)
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ def handle(self, *args, **options):
tarball = tasks.create_export_tarball(library, library_key, {}, None)
except Exception as e:
raise CommandError(f'Failed to export "{library_key}" with "{e}"') # lint-amnesty, pylint: disable=raise-missing-from
else:
with tarball:
# Save generated archive with keyed filename
prefix, suffix, n = str(library_key).replace(':', '+'), '.tar.gz', 0
while os.path.exists(prefix + suffix):
n += 1
prefix = '{}_{}'.format(prefix.rsplit('_', 1)[0], n) if n > 1 else f'{prefix}_1'
filename = prefix + suffix
target = os.path.join(dest_path, filename)
tarball.file.seek(0)
with open(target, 'wb') as f:
shutil.copyfileobj(tarball.file, f)
print(f'Library "{library.location.library_key}" exported to "{target}"')
with tarball:
# Save generated archive with keyed filename
prefix, suffix, n = str(library_key).replace(':', '+'), '.tar.gz', 0
while os.path.exists(prefix + suffix):
n += 1
prefix = '{}_{}'.format(prefix.rsplit('_', 1)[0], n) if n > 1 else f'{prefix}_1'
filename = prefix + suffix
target = os.path.join(dest_path, filename)
tarball.file.seek(0)
with open(target, 'wb') as f:
shutil.copyfileobj(tarball.file, f)
print(f'Library "{library.location.library_key}" exported to "{target}"')
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def handle(self, *args, **options):
self.change_enrollments(csv_file)

else:
CommandError('No file is provided. File is required')
raise CommandError('No file is provided. File is required')

def change_enrollments(self, csv_file):
""" change the enrollments of the learners. """
Expand Down
5 changes: 2 additions & 3 deletions common/djangoapps/track/views/segmentio.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ def track_segmentio_event(request): # pylint: disable=too-many-statements
raise EventValidationError(ERROR_USER_NOT_EXIST) # lint-amnesty, pylint: disable=raise-missing-from
except ValueError:
raise EventValidationError(ERROR_INVALID_USER_ID) # lint-amnesty, pylint: disable=raise-missing-from
else:
context['user_id'] = user.id
context['username'] = user.username
context['user_id'] = user.id
context['username'] = user.username

# course_id is expected to be provided in the context when applicable
course_id = context.get('course_id')
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/discussion/rest_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ def get_thread_list(
if view in ["unread", "unanswered", "unresponded"]:
query_params[view] = "true"
else:
ValidationError({
raise ValidationError({
"view": [f"Invalid value. '{view}' must be 'unread' or 'unanswered'"]
})

Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/experiments/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def get_bucket(self, course_key=None, track=True):
if (
track and hasattr(request, 'session') and
session_key not in request.session and
not masquerading_as_specific_student and not anonymous
not masquerading_as_specific_student and not anonymous # pylint: disable=used-before-assignment
):
segment.track(
user_id=user.id,
Expand Down
3 changes: 1 addition & 2 deletions lms/djangoapps/static_template_view/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def render_press_release(request, slug):
resp = render_to_response('static_templates/press_releases/' + template, {})
except TemplateDoesNotExist:
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from
else:
return resp
return resp


@fix_crum_request
Expand Down
3 changes: 1 addition & 2 deletions openedx/core/djangoapps/credit/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def update_credit_course_requirements(course_id):
except (InvalidKeyError, ItemNotFoundError, InvalidCreditRequirements) as exc:
LOGGER.error('Error on adding the requirements for course %s - %s', course_id, str(exc))
raise update_credit_course_requirements.retry(args=[course_id], exc=exc)
else:
LOGGER.info('Requirements added for course %s', course_id)
LOGGER.info('Requirements added for course %s', course_id)


def _get_course_credit_requirements(course_key):
Expand Down
3 changes: 1 addition & 2 deletions openedx/core/djangoapps/enrollments/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ def get_course_enrollment_info(course_id, include_expired=False):
msg = f"Requested enrollment information for unknown course {course_id}"
log.warning(msg)
raise CourseNotFoundError(msg) # lint-amnesty, pylint: disable=raise-missing-from
else:
return CourseSerializer(course, include_expired=include_expired).data
return CourseSerializer(course, include_expired=include_expired).data


def get_user_roles(username):
Expand Down
15 changes: 7 additions & 8 deletions openedx/core/djangoapps/safe_sessions/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,13 @@ def parse(cls, safe_cookie_string):
raise SafeCookieError( # lint-amnesty, pylint: disable=raise-missing-from
f"SafeCookieData BWC parse error: {safe_cookie_string!r}."
)
else:
if safe_cookie_data.version != cls.CURRENT_VERSION:
raise SafeCookieError(
"SafeCookieData version {!r} is not supported. Current version is {}.".format(
safe_cookie_data.version,
cls.CURRENT_VERSION,
))
return safe_cookie_data
if safe_cookie_data.version != cls.CURRENT_VERSION:
raise SafeCookieError(
"SafeCookieData version {!r} is not supported. Current version is {}.".format(
safe_cookie_data.version,
cls.CURRENT_VERSION,
))
return safe_cookie_data

def __str__(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ def handle(self, *args, **options):
optout_rows[end_idx][0], optout_rows[end_idx][1],
str(err))
raise
else:
cursor.execute('COMMIT;')
log.info("Committed opt-out for rows (%s, %s) through (%s, %s).",
optout_rows[start_idx][0], optout_rows[start_idx][1],
optout_rows[end_idx][0], optout_rows[end_idx][1])
cursor.execute('COMMIT;')
log.info("Committed opt-out for rows (%s, %s) through (%s, %s).",
optout_rows[start_idx][0], optout_rows[start_idx][1],
optout_rows[end_idx][0], optout_rows[end_idx][1])
log.info("Sleeping %s seconds...", sleep_between)
time.sleep(sleep_between)
curr_row_idx += chunk_size
3 changes: 1 addition & 2 deletions openedx/core/lib/api/view_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ def __len__(self):

def __iter__(self):
# Yield all the known data first
for item in self._data:
yield item
yield from self._data

# Capture and yield data from the underlying iterator
# until it is exhausted
Expand Down
5 changes: 2 additions & 3 deletions openedx/core/lib/celery/task_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ def emulate_http_request(site=None, user=None, middleware_classes=None):
for middleware in reversed(middleware_instances):
_run_method_if_implemented(middleware, 'process_exception', request, exc)
raise
else:
for middleware in reversed(middleware_instances):
_run_method_if_implemented(middleware, 'process_response', request, response)
for middleware in reversed(middleware_instances):
_run_method_if_implemented(middleware, 'process_response', request, response)


def _run_method_if_implemented(instance, method_name, *args, **kwargs):
Expand Down
7 changes: 1 addition & 6 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,6 @@ disable =
superfluous-parens,
logging-not-lazy,
broad-exception-caught,
no-else-raise,
pointless-exception-statement,
consider-using-join,
use-yield-from,
used-before-assignment,

[REPORTS]
output-format = text
Expand Down Expand Up @@ -422,4 +417,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = builtins.Exception

# 86de3cc2b03ecf7e6f6f9f2d5f790bb9e7c3eb4c
# 85c3d025c367597a0a7b23a05fdde9d8c63e1374
6 changes: 0 additions & 6 deletions pylintrc_tweaks
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ disable+ =
superfluous-parens,
logging-not-lazy,
broad-exception-caught,
no-else-raise,
pointless-exception-statement,
consider-using-join,
use-yield-from,
used-before-assignment,


[BASIC]
attr-rgx = [a-z_][a-z0-9_]{2,40}$
Expand Down
3 changes: 1 addition & 2 deletions xmodule/capa/tests/test_input_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def render_to_xml(self, context_dict):
except Exception as exc:
raise TemplateError("Could not parse XML from '{0}': {1}".format( # lint-amnesty, pylint: disable=raise-missing-from
xml_str, str(exc)))
else:
return xml
return xml

def assert_has_xpath(self, xml_root, xpath, context_dict, exact_num=1):
"""
Expand Down
5 changes: 2 additions & 3 deletions xmodule/split_test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,8 @@ def log_child_render(self, request, suffix=''): # lint-amnesty, pylint: disable
)
)
raise
else:
self.runtime.publish(self, 'xblock.split_test.child_render', {'child_id': child_id})
return Response()
self.runtime.publish(self, 'xblock.split_test.child_render', {'child_id': child_id})
return Response()

def get_icon_class(self):
return self.child.get_icon_class() if self.child else 'other'
Expand Down
Loading