fix: fix pylint warnings (#29049)
This commit is contained in:
@@ -405,7 +405,7 @@ def get_component_templates(courselike, library=False): # lint-amnesty, pylint:
|
||||
# Set component types according to course policy file
|
||||
if isinstance(course_advanced_keys, list):
|
||||
for category in course_advanced_keys:
|
||||
if category in advanced_component_types.keys() and category not in categories:
|
||||
if category in advanced_component_types.keys() and category not in categories: # pylint: disable=consider-iterating-dictionary
|
||||
# boilerplates not supported for advanced components
|
||||
try:
|
||||
component_display_name = xblock_type_display_name(category, default_display_name=category)
|
||||
|
||||
@@ -916,7 +916,7 @@ def _create_or_rerun_course(request):
|
||||
return JsonResponse({
|
||||
"ErrMsg": _("Unable to create course '{name}'.\n\n{err}").format(name=display_name, err=str(error))}
|
||||
)
|
||||
except PermissionDenied as error:
|
||||
except PermissionDenied as error: # pylint: disable=unused-variable
|
||||
log.info(
|
||||
"User does not have the permission to create course in this organization"
|
||||
"or course creation is disabled."
|
||||
|
||||
@@ -208,7 +208,7 @@ def _create_library(request):
|
||||
)
|
||||
# Give the user admin ("Instructor") role for this library:
|
||||
add_instructor(new_lib.location.library_key, request.user, request.user)
|
||||
except PermissionDenied as error:
|
||||
except PermissionDenied as error: # pylint: disable=unused-variable
|
||||
log.info(
|
||||
"User does not have the permission to create LIBRARY in this organization."
|
||||
"User: '%s' Org: '%s' LIBRARY #: '%s'.",
|
||||
|
||||
@@ -79,7 +79,7 @@ def post_save_callback(sender, **kwargs):
|
||||
# We need to keep track of all_organization switch. If this switch is changed we are going to remove the
|
||||
# Course Creator group.
|
||||
if instance.state != instance.orig_state or instance.all_organizations != instance.orig_all_organizations:
|
||||
granted_state_change = instance.state == CourseCreator.GRANTED or instance.orig_state == CourseCreator.GRANTED
|
||||
granted_state_change = instance.state == CourseCreator.GRANTED or instance.orig_state == CourseCreator.GRANTED # pylint: disable=consider-using-in
|
||||
# If either old or new state is 'granted', we must manipulate the course creator
|
||||
# group maintained by authz. That requires staff permissions (stored admin).
|
||||
if granted_state_change:
|
||||
|
||||
@@ -154,7 +154,7 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler):
|
||||
Each POST parameter is the configuration key.
|
||||
Each POST value is a JSON-encoded string value for the configuration.
|
||||
"""
|
||||
if self.path == "/set_config" or self.path == "/set_config/":
|
||||
if self.path in ("/set_config", "/set_config/"):
|
||||
|
||||
if len(self.post_dict) > 0:
|
||||
for key, value in self.post_dict.items():
|
||||
|
||||
@@ -40,7 +40,7 @@ class StubYouTubeHandler(StubHttpRequestHandler):
|
||||
"""
|
||||
Allow callers to delete all the server configurations using the /del_config URL.
|
||||
"""
|
||||
if self.path == "/del_config" or self.path == "/del_config/":
|
||||
if self.path in ("/del_config", "/del_config/"):
|
||||
self.server.config = {}
|
||||
self.log_message("Reset Server Configuration.")
|
||||
self.send_response(200)
|
||||
|
||||
@@ -236,7 +236,7 @@ def strftime_localized_html(dtime, fmt):
|
||||
format_mapping = {
|
||||
'SHORT_DATE': 'shortDate',
|
||||
}
|
||||
assert fmt in format_mapping.keys(), 'format "%s" not yet supported in strftime_localized_html' % fmt
|
||||
assert fmt in format_mapping.keys(), 'format "%s" not yet supported in strftime_localized_html' % fmt # pylint: disable=consider-iterating-dictionary
|
||||
|
||||
date_html = '<span class="localized-datetime" data-format="{format}" data-timezone="{user_timezone}" \
|
||||
data-datetime="{formatted_date}" data-language="{language}">{formatted_date_localized}</span>'
|
||||
|
||||
@@ -35,7 +35,7 @@ def decompress_string(value):
|
||||
"""
|
||||
|
||||
try:
|
||||
val = value.encode('utf').decode('base64') # lint-amnesty, pylint: disable=invalid-str-codec
|
||||
val = value.encode('utf').decode('base64') # pylint: disable=invalid-str-codec
|
||||
zbuf = BytesIO(val)
|
||||
zfile = gzip.GzipFile(fileobj=zbuf)
|
||||
ret = zfile.read()
|
||||
@@ -60,7 +60,7 @@ class CompressedTextField(CreatorMixin, models.TextField):
|
||||
if isinstance(value, str):
|
||||
value = value.encode('utf8')
|
||||
value = compress_string(value)
|
||||
value = value.encode('base64').decode('utf8') # lint-amnesty, pylint: disable=invalid-str-codec
|
||||
value = value.encode('base64').decode('utf8') # pylint: disable=invalid-str-codec
|
||||
return value
|
||||
|
||||
def to_python(self, value):
|
||||
|
||||
@@ -229,7 +229,7 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None
|
||||
# if expected answer is a number, try parsing provided answer as a number also
|
||||
try:
|
||||
fans = my_sympify(str(ans), matrix=do_matrix, do_qubit=do_qubit)
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except, unused-variable
|
||||
fans = None
|
||||
|
||||
# do a numerical comparison if both expected and answer are numbers
|
||||
|
||||
@@ -103,7 +103,7 @@ edx_xml_parser = etree.XMLParser(dtd_validation=False, load_dtd=False,
|
||||
_cached_toc = {}
|
||||
|
||||
|
||||
class Textbook: # lint-amnesty, pylint: disable=missing-class-docstring,eq-without-hash
|
||||
class Textbook: # lint-amnesty, pylint: disable=missing-class-docstring, eq-without-hash
|
||||
def __init__(self, title, book_url):
|
||||
self.title = title
|
||||
self.book_url = book_url
|
||||
@@ -146,7 +146,7 @@ class Textbook: # lint-amnesty, pylint: disable=missing-class-docstring,eq-with
|
||||
# expire every 10 minutes
|
||||
if age.seconds < 600:
|
||||
return table_of_contents
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except
|
||||
except Exception as err: # lint-amnesty, pylint: disable=broad-except, unused-variable
|
||||
pass
|
||||
|
||||
# Get the table of contents from S3
|
||||
|
||||
@@ -647,7 +647,7 @@ class CourseImportManager(ImportManager):
|
||||
courselike_key.course,
|
||||
courselike_key.run
|
||||
)
|
||||
if course.wiki_slug == original_unique_wiki_slug or course.wiki_slug == courselike_key.course:
|
||||
if course.wiki_slug in (original_unique_wiki_slug, courselike_key.course):
|
||||
course.wiki_slug = '{}.{}.{}'.format(
|
||||
course.id.org,
|
||||
course.id.course,
|
||||
|
||||
@@ -422,7 +422,7 @@ class CourseTabList(List):
|
||||
|
||||
# find one of the discussion tab types in the course tabs
|
||||
for tab in course.tabs:
|
||||
if tab.type == 'discussion' or tab.type == 'external_discussion':
|
||||
if tab.type in ('discussion', 'external_discussion'):
|
||||
return tab
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user