diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 713222d322..7a2408e209 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -435,7 +435,7 @@ class LoncapaProblem(object): # if answers include File objects, convert them to filenames. self.student_answers = convert_files_to_filenames(answers) new_cmap = self.get_grade_from_current_answers(answers) - self.correct_map = new_cmap + self.correct_map = new_cmap # lint-amnesty, pylint: disable=attribute-defined-outside-init return self.correct_map def supports_rescoring(self): @@ -506,7 +506,7 @@ class LoncapaProblem(object): """ # dict of (id, correct_answer) answer_map = dict() - for response in self.responders.keys(): + for response in self.responders.keys(): # lint-amnesty, pylint: disable=consider-iterating-dictionary results = self.responder_answers[response] answer_map.update(results) @@ -526,7 +526,7 @@ class LoncapaProblem(object): get_question_answers may only return a subset of these. """ answer_ids = [] - for response in self.responders.keys(): + for response in self.responders.keys(): # lint-amnesty, pylint: disable=consider-iterating-dictionary results = self.responder_answers[response] answer_ids.append(list(results.keys())) return answer_ids @@ -809,7 +809,7 @@ class LoncapaProblem(object): try: # open using LoncapaSystem OSFS filestore ifp = self.capa_system.filestore.open(filename) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.warning( 'Error %s in problem xml include: %s', err, @@ -820,14 +820,14 @@ class LoncapaProblem(object): ) # if debugging, don't fail - just log error # TODO (vshnayder): need real error handling, display to users - if not self.capa_system.DEBUG: + if not self.capa_system.DEBUG: # lint-amnesty, pylint: disable=no-else-raise raise else: continue try: # read in and convert to XML incxml = etree.XML(ifp.read()) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except log.warning( 'Error %s in problem xml include: %s', err, @@ -836,7 +836,7 @@ class LoncapaProblem(object): log.warning('Cannot parse XML in %s', (filename)) # if debugging, don't fail - just log error # TODO (vshnayder): same as above - if not self.capa_system.DEBUG: + if not self.capa_system.DEBUG: # lint-amnesty, pylint: disable=no-else-raise raise else: continue @@ -864,7 +864,7 @@ class LoncapaProblem(object): # find additional comma-separated modules search path path = [] - for dir in raw_path: + for dir in raw_path: # lint-amnesty, pylint: disable=redefined-builtin if not dir: continue @@ -937,7 +937,7 @@ class LoncapaProblem(object): unsafely=self.capa_system.can_execute_unsafe_code(), ) except Exception as err: - log.exception("Error while execing script code: " + all_code) + log.exception("Error while execing script code: " + all_code) # lint-amnesty, pylint: disable=logging-not-lazy msg = Text("Error while executing script code: %s" % str(err)) raise responsetypes.LoncapaProblemError(msg) @@ -1111,7 +1111,7 @@ class LoncapaProblem(object): # get responder answers (do this only once, since there may be a performance cost, # eg with externalresponse) self.responder_answers = {} - for response in self.responders.keys(): + for response in self.responders.keys(): # lint-amnesty, pylint: disable=consider-iterating-dictionary try: self.responder_answers[response] = self.responders[response].get_answers() except: diff --git a/common/lib/capa/capa/checker.py b/common/lib/capa/capa/checker.py index b575c4aec2..872e9bf9d2 100755 --- a/common/lib/capa/capa/checker.py +++ b/common/lib/capa/capa/checker.py @@ -19,7 +19,7 @@ logging.basicConfig(format="%(levelname)s %(message)s") log = logging.getLogger('capa.checker') -class DemoSystem(object): +class DemoSystem(object): # lint-amnesty, pylint: disable=missing-class-docstring def __init__(self): self.lookup = TemplateLookup(directories=[path(__file__).dirname() / 'templates']) self.DEBUG = True @@ -31,7 +31,7 @@ class DemoSystem(object): return self.lookup.get_template(template_filename).render(**dictionary) -def main(): +def main(): # lint-amnesty, pylint: disable=missing-function-docstring parser = argparse.ArgumentParser(description='Check Problem Files') parser.add_argument("command", choices=['test', 'show']) # Watch? Render? Open? parser.add_argument("files", nargs="+", type=argparse.FileType('r')) @@ -49,8 +49,8 @@ def main(): log.info("Opening {0}".format(problem_file.name)) try: - problem = LoncapaProblem(problem_file, "fakeid", seed=args.seed, system=system) - except Exception as ex: + problem = LoncapaProblem(problem_file, "fakeid", seed=args.seed, system=system) # lint-amnesty, pylint: disable=no-value-for-parameter, unexpected-keyword-arg + except Exception as ex: # lint-amnesty, pylint: disable=broad-except log.error("Could not parse file {0}".format(problem_file.name)) log.exception(ex) continue @@ -70,7 +70,7 @@ def command_show(problem): print(problem.get_html()) -def command_test(problem): +def command_test(problem): # lint-amnesty, pylint: disable=missing-function-docstring # We're going to trap stdout/stderr from the problems (yes, some print) old_stdout, old_stderr = sys.stdout, sys.stderr try: @@ -84,7 +84,7 @@ def command_test(problem): "captured stdout from {0}".format(problem)) log_captured_output(sys.stderr, "captured stderr from {0}".format(problem)) - except Exception as e: + except Exception as e: # lint-amnesty, pylint: disable=broad-except log.exception(e) finally: sys.stdout, sys.stderr = old_stdout, old_stderr @@ -135,7 +135,7 @@ def check_that_suggested_answers_work(problem): assert(all(result == 'correct' for answer_id, result in real_results.items())) except UndefinedVariable as uv_exc: - log.error("The variable \"{0}\" specified in the ".format(uv_exc) + + log.error("The variable \"{0}\" specified in the ".format(uv_exc) + # lint-amnesty, pylint: disable=logging-not-lazy "solution isn't recognized (is it a units measure?).") except AssertionError: log.error("The following generated answers were not accepted for {0}:" @@ -143,16 +143,16 @@ def check_that_suggested_answers_work(problem): for question_id, result in sorted(real_results.items()): if result != 'correct': log.error(" {0} = {1}".format(question_id, real_answers[question_id])) - except Exception as ex: + except Exception as ex: # lint-amnesty, pylint: disable=broad-except log.error("Uncaught error in {0}".format(problem)) log.exception(ex) -def log_captured_output(output_stream, stream_name): +def log_captured_output(output_stream, stream_name): # lint-amnesty, pylint: disable=missing-function-docstring output_stream.seek(0) output_text = output_stream.read() if output_text: - log.info("##### Begin {0} #####\n".format(stream_name) + output_text) + log.info("##### Begin {0} #####\n".format(stream_name) + output_text) # lint-amnesty, pylint: disable=logging-not-lazy log.info("##### End {0} #####".format(stream_name)) diff --git a/common/lib/capa/capa/correctmap.py b/common/lib/capa/capa/correctmap.py index 85376fb526..07ae3f9659 100644 --- a/common/lib/capa/capa/correctmap.py +++ b/common/lib/capa/capa/correctmap.py @@ -1,4 +1,4 @@ -# ----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # lint-amnesty, pylint: disable=missing-module-docstring # class used to store graded responses to CAPA questions # # Used by responsetypes and capa_problem @@ -38,8 +38,8 @@ class CorrectMap(object): return self.cmap.__iter__() # See the documentation for 'set_dict' for the use of kwargs - def set( - self, + def set( # lint-amnesty, pylint: disable=missing-function-docstring + self, # lint-amnesty, pylint: disable=unused-argument answer_id=None, correctness=None, npoints=None, @@ -47,7 +47,7 @@ class CorrectMap(object): hint='', hintmode=None, queuestate=None, - answervariable=None, # pylint: disable=C0330 + answervariable=None, # lint-amnesty, pylint: disable=C0330, bad-option-value **kwargs ): @@ -144,13 +144,13 @@ class CorrectMap(object): # if not correct and no points have been assigned, return 0 return 0 - def set_property(self, answer_id, property, value): + def set_property(self, answer_id, property, value): # lint-amnesty, pylint: disable=redefined-builtin if answer_id in self.cmap: self.cmap[answer_id][property] = value else: self.cmap[answer_id] = {property: value} - def get_property(self, answer_id, property, default=None): + def get_property(self, answer_id, property, default=None): # lint-amnesty, pylint: disable=redefined-builtin if answer_id in self.cmap: return self.cmap[answer_id].get(property, default) return default diff --git a/common/lib/capa/capa/customrender.py b/common/lib/capa/capa/customrender.py index 9615abbaa5..4d4669bf6d 100644 --- a/common/lib/capa/capa/customrender.py +++ b/common/lib/capa/capa/customrender.py @@ -24,7 +24,7 @@ registry = TagRegistry() # ----------------------------------------------------------------------------- -class MathRenderer(object): +class MathRenderer(object): # lint-amnesty, pylint: disable=missing-class-docstring tags = ['math'] def __init__(self, system, xml): @@ -57,11 +57,11 @@ class MathRenderer(object): """ # TODO: why are there nested html tags here?? Why are there html tags at all, in fact? # xss-lint: disable=python-interpolate-html - html = '%s%s' % ( + html = '%s%s' % ( # lint-amnesty, pylint: disable=redefined-outer-name self.mathstr, saxutils.escape(self.xml.tail)) try: xhtml = etree.XML(html) - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except if self.system.DEBUG: # xss-lint: disable=python-interpolate-html msg = '

Error %s

' % ( @@ -99,7 +99,7 @@ class SolutionRenderer(object): def get_html(self): context = {'id': self.id} - html = self.system.render_template("solutionspan.html", context) + html = self.system.render_template("solutionspan.html", context) # lint-amnesty, pylint: disable=redefined-outer-name return etree.XML(html) @@ -175,7 +175,7 @@ class ClarificationRenderer(object): Return the contents of this tag, rendered to html, as an etree element. """ context = {'clarification': self.inner_html} - html = self.system.render_template("clarification.html", context) + html = self.system.render_template("clarification.html", context) # lint-amnesty, pylint: disable=redefined-outer-name xml = etree.XML(html) # We must include any text that was following our original ... XML node.: xml.tail = self.tail diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index be20cdd9f9..b18beec8e3 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -254,7 +254,7 @@ class InputTypeBase(object): # super().__init__, and are isolated from changes to the input # constructor interface. self.setup() - except Exception as err: + except Exception as err: # lint-amnesty, pylint: disable=broad-except # Something went wrong: add xml to message, but keep the traceback msg = u"Error in xml '{x}': {err} ".format( x=etree.tostring(xml), err=text_type(err)) @@ -298,7 +298,7 @@ class InputTypeBase(object): If this method raises an exception, it will be wrapped with a message that includes the problem xml. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def handle_ajax(self, dispatch, data): """ @@ -311,7 +311,7 @@ class InputTypeBase(object): Output: a dictionary object that can be serialized into JSON. This will be sent back to the Javascript. """ - pass + pass # lint-amnesty, pylint: disable=unnecessary-pass def _get_render_context(self): """ @@ -384,11 +384,11 @@ class InputTypeBase(object): output = etree.XML(html) except etree.XMLSyntaxError as ex: # If `html` contains attrs with no values, like `controls` in