fix: fix pylint warnings (#29049)

This commit is contained in:
Usama Sadiq
2021-10-20 16:28:18 +05:00
committed by GitHub
parent 5a6d056568
commit ab4c14afe3
12 changed files with 14 additions and 14 deletions

View File

@@ -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():

View File

@@ -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)

View File

@@ -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>'

View File

@@ -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):

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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