From 0b01efcfa069b8b53f6513a64bcbab2ef8c1ae83 Mon Sep 17 00:00:00 2001 From: Jawayria Date: Wed, 15 Jun 2022 18:58:45 +0500 Subject: [PATCH] fix: quality --- calc/calc.py | 8 +-- calc/preview.py | 8 +-- pylintrc | 108 ++------------------------------------- symmath/symmath_check.py | 2 +- tests/test_calc.py | 4 +- 5 files changed, 14 insertions(+), 116 deletions(-) diff --git a/calc/calc.py b/calc/calc.py index d82d7f2..a128a61 100644 --- a/calc/calc.py +++ b/calc/calc.py @@ -256,9 +256,9 @@ def evaluator(variables, unary_functions, math_expr, case_sensitive=False): # Create a recursion to evaluate the tree. if case_sensitive: - casify = lambda x: x + casify = lambda x: x # pylint: disable=unnecessary-lambda-assignment else: - casify = lambda x: x.lower() # Lowercase for case insens. + casify = lambda x: x.lower() # pylint: disable=unnecessary-lambda-assignment # Lowercase for case insens. evaluate_actions = { 'number': eval_number, @@ -453,9 +453,9 @@ def check_variables(self, valid_variables, valid_functions): Otherwise, raise an UndefinedVariable containing all bad variables. """ if self.case_sensitive: - casify = lambda x: x + casify = lambda x: x # pylint: disable=unnecessary-lambda-assignment else: - casify = lambda x: x.lower() # Lowercase for case insens. + casify = lambda x: x.lower() # Lowercase for case insens. # pylint: disable=unnecessary-lambda-assignment bad_vars = {var for var in self.variables_used if casify(var) not in valid_variables} diff --git a/calc/preview.py b/calc/preview.py index b9c44bb..352dccc 100644 --- a/calc/preview.py +++ b/calc/preview.py @@ -210,7 +210,7 @@ def render_power(children): children_latex = [k.latex for k in children if k.latex != "^"] children_latex[-1] = children[-1].sans_parens - raise_power = lambda x, y: f"{y}^{{{x}}}" + raise_power = lambda x, y: f"{y}^{{{x}}}" # pylint: disable=unnecessary-lambda-assignment latex = reduce(raise_power, reversed(children_latex)) return LatexRendered(latex, tall=True) @@ -373,9 +373,9 @@ def latex_preview(math_expr, variables=(), functions=(), case_sensitive=False): # Create a recursion to evaluate the tree. if case_sensitive: - casify = lambda x: x + casify = lambda x: x # pylint: disable=unnecessary-lambda-assignment else: - casify = lambda x: x.lower() # Lowercase for case insens. + casify = lambda x: x.lower() # pylint: disable=unnecessary-lambda-assignment # Lowercase for case insens. render_actions = { 'number': render_number, @@ -389,7 +389,7 @@ def latex_preview(math_expr, variables=(), functions=(), case_sensitive=False): } backslash = "\\" - wrap_escaped_strings = lambda s: LatexRendered( + wrap_escaped_strings = lambda s: LatexRendered( # pylint: disable=unnecessary-lambda-assignment s.replace(backslash, backslash * 2) ) diff --git a/pylintrc b/pylintrc index 8ed6c2a..e2e1a3a 100644 --- a/pylintrc +++ b/pylintrc @@ -64,12 +64,12 @@ # SERIOUSLY. # # ------------------------------ -# Generated by edx-lint version: 5.2.1 +# Generated by edx-lint version: 5.2.4 # ------------------------------ [MASTER] ignore = persistent = yes -load-plugins = edx_lint.pylint,pylint_celery +load-plugins = edx_lint.pylint,pylint_django,pylint_celery [MESSAGES CONTROL] enable = @@ -102,20 +102,12 @@ enable = cell-var-from-loop, confusing-with-statement, continue-in-finally, - cyclical-import, dangerous-default-value, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, duplicate-argument-name, duplicate-bases, duplicate-except, duplicate-key, - eq-without-hash, - exception-escape, - exception-message-attribute, expression-not-assigned, - filter-builtin-not-iterating, format-combined-specification, format-needs-mapping, function-redefined, @@ -123,33 +115,26 @@ enable = import-error, import-self, inconsistent-mro, - indexing-exception, inherit-non-class, init-is-generator, invalid-all-object, - invalid-encoded-data, invalid-format-index, invalid-length-returned, invalid-sequence-index, invalid-slice-index, invalid-slots-object, invalid-slots, - invalid-str-codec, invalid-unary-operand-type, logging-too-few-args, logging-too-many-args, logging-unsupported-format, lost-exception, - map-builtin-not-iterating, method-hidden, misplaced-bare-raise, misplaced-future, missing-format-argument-key, missing-format-attribute, missing-format-string-key, - missing-super-argument, - mixed-fomat-string, - model-unicode-not-callable, no-member, no-method-argument, no-name-in-module, @@ -158,8 +143,6 @@ enable = non-iterator-returned, non-parent-method-called, nonexistent-operator, - nonimplemented-raised, - nonstandard-exception, not-a-mapping, not-an-iterable, not-callable, @@ -167,35 +150,25 @@ enable = not-in-loop, pointless-statement, pointless-string-statement, - property-on-old-class, raising-bad-type, raising-non-exception, - raising-string, - range-builtin-not-iterating, redefined-builtin, - redefined-in-handler, redefined-outer-name, - redefined-variable-type, redundant-keyword-arg, - relative-import, repeated-keyword, return-arg-in-generator, return-in-init, return-outside-function, signature-differs, - slots-on-old-class, super-init-not-called, super-method-not-called, - super-on-old-class, syntax-error, - sys-max-int, test-inherits-tests, too-few-format-args, too-many-format-args, too-many-function-args, translation-of-non-string, truncated-format-string, - unbalance-tuple-unpacking, undefined-all-variable, undefined-loop-variable, undefined-variable, @@ -211,11 +184,8 @@ enable = used-before-assignment, using-constant-test, yield-outside-function, - zip-builtin-not-iterating, astroid-error, - django-not-available-placeholder, - django-not-available, fatal, method-check-failed, parse-error, @@ -237,7 +207,6 @@ enable = bad-classmethod-argument, bad-mcs-classmethod-argument, bad-mcs-method-argument, - bad-whitespace, bare-except, broad-except, consider-iterating-dictionary, @@ -247,16 +216,10 @@ enable = literal-used-as-attribute, logging-format-interpolation, logging-not-lazy, - metaclass-assignment, - model-has-unicode, - model-missing-unicode, - model-no-explicit-unicode, multiple-imports, multiple-statements, no-classmethod-decorator, no-staticmethod-decorator, - old-raise-syntax, - old-style-class, protected-access, redundant-unittest-assert, reimported, @@ -284,7 +247,6 @@ enable = wrong-import-position, missing-final-newline, - mixed-indentation, mixed-line-endings, trailing-newlines, trailing-whitespace, @@ -295,25 +257,7 @@ enable = deprecated-pragma, unrecognized-inline-option, useless-suppression, - - cmp-method, - coerce-method, - delslice-method, - dict-iter-method, - dict-view-method, - div-method, - getslice-method, - hex-method, - idiv-method, - next-method-called, - next-method-defined, - nonzero-method, - oct-method, - rdiv-method, - setslice-method, - using-cmp-argument, disable = - bad-continuation, bad-indentation, consider-using-f-string, duplicate-code, @@ -322,12 +266,7 @@ disable = global-statement, invalid-name, locally-disabled, - locally-enabled, - lowercase-l-suffix, - misplaced-comparison-constant, no-else-return, - no-init, - no-self-use, suppressed-message, too-few-public-methods, too-many-ancestors, @@ -346,54 +285,14 @@ disable = feature-toggle-needs-doc, illegal-waffle-usage, - apply-builtin, - backtick, - bad-python3-import, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - deprecated-itertools-function, - deprecated-operator-function, - deprecated-str-translate-call, - deprecated-string-function, - deprecated-sys-function, - deprecated-types-field, - deprecated-urllib-function, - execfile-builtin, - file-builtin, - import-star-module-level, - input-builtin, - intern-builtin, - long-builtin, - long-suffix, - no-absolute-import, - non-ascii-bytes-literal, - old-division, - old-ne-operator, - old-octal-literal, - parameter-unpacking, - print-statement, - raw_input-builtin, - reduce-builtin, - reload-builtin, - round-builtin, - standarderror-builtin, - unichr-builtin, - unicode-builtin, - unpacking-in-except, - xrange-builtin, - logging-fstring-interpolation, [REPORTS] output-format = text -files-output = no reports = no score = no [BASIC] -bad-functions = map,filter,apply,input module-rgx = (([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ const-rgx = (([A-Z_][A-Z0-9_]*)|(__.*__)|log|urlpatterns)$ class-rgx = [A-Z_][a-zA-Z0-9]+$ @@ -413,7 +312,6 @@ docstring-min-length = 5 max-line-length = 120 ignore-long-lines = ^\s*(# )?((?)|(\.\. \w+: .*))$ single-line-if-stmt = no -no-space-check = trailing-comma,dict-separator max-module-lines = 1000 indent-string = ' ' @@ -484,4 +382,4 @@ int-import-graph = [EXCEPTIONS] overgeneral-exceptions = Exception -# 0cfdab5f522ca16c0e457065f6599c832489a460 +# fad4071fe38e655a180214bd3f6bce3ffa41b2ed diff --git a/symmath/symmath_check.py b/symmath/symmath_check.py index 1d13207..0ea480c 100644 --- a/symmath/symmath_check.py +++ b/symmath/symmath_check.py @@ -37,7 +37,7 @@ def symmath_check_simple(expect, ans, adict={}, symtab=None, extra_options=None) for op in options: # find options in expect string if op in expect: expect = expect.replace(op, '') - options[op] = True + options[op] = True # pylint: disable=modified-iterating-dict expect = expect.replace('__OR__', '__or__') # backwards compatibility if options['__LOWER__']: diff --git a/tests/test_calc.py b/tests/test_calc.py index 72f95c7..9a2b679 100644 --- a/tests/test_calc.py +++ b/tests/test_calc.py @@ -35,7 +35,7 @@ def test_number_input(self): test_exponential_answer test_si_suffix """ - easy_eval = lambda x: calc.evaluator({}, {}, x) + easy_eval = lambda x: calc.evaluator({}, {}, x) # pylint: disable=unnecessary-lambda-assignment self.assertEqual(easy_eval("13"), 13) self.assertEqual(easy_eval("3.14"), 3.14) @@ -238,7 +238,7 @@ def test_hyperbolic_functions(self): """ inputs = ['0', '0.5', '1', '2', '1+j'] neg_inputs = ['0', '-0.5', '-1', '-2', '-1-j'] - negate = lambda x: [-k for k in x] + negate = lambda x: [-k for k in x] # pylint: disable=unnecessary-lambda-assignment # sinh is odd sinh_vals = [0, 0.521, 1.175, 3.627, 0.635 + 1.298j]