Skip to content

Commit

Permalink
fix: quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawayria committed Jun 15, 2022
1 parent a1ccfcb commit 0b01efc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 116 deletions.
8 changes: 4 additions & 4 deletions calc/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions calc/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand All @@ -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)
)

Expand Down
108 changes: 3 additions & 105 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -102,54 +102,39 @@ 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,
global-variable-undefined,
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,
Expand All @@ -158,44 +143,32 @@ enable =
non-iterator-returned,
non-parent-method-called,
nonexistent-operator,
nonimplemented-raised,
nonstandard-exception,
not-a-mapping,
not-an-iterable,
not-callable,
not-context-manager,
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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -284,7 +247,6 @@ enable =
wrong-import-position,

missing-final-newline,
mixed-indentation,
mixed-line-endings,
trailing-newlines,
trailing-whitespace,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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]+$
Expand All @@ -413,7 +312,6 @@ docstring-min-length = 5
max-line-length = 120
ignore-long-lines = ^\s*(# )?((<?https?://\S+>?)|(\.\. \w+: .*))$
single-line-if-stmt = no
no-space-check = trailing-comma,dict-separator
max-module-lines = 1000
indent-string = ' '

Expand Down Expand Up @@ -484,4 +382,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = Exception

# 0cfdab5f522ca16c0e457065f6599c832489a460
# fad4071fe38e655a180214bd3f6bce3ffa41b2ed
2 changes: 1 addition & 1 deletion symmath/symmath_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__']:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 0b01efc

Please sign in to comment.