Closed tonybaloney closed 2 years ago
Another one for you:
from collections import Counter
def main():
target = 'crate'
target_s = set(target)
target_c = Counter(target)
for word in ('trace', 'cater'):
c = Counter(word)
if (
target_s.issuperset(word) and
all(target_c[k] >= v for k, v in c.items())
):
print(f'{target} {word}')
if __name__ == '__main__':
main()
Gets these warnings:
❯ pylint --load-plugins perflint ../perlint-test.py
************* Module hughbrown.perlint-test
/Users/hughbrown/perlint-test.py:1:0: C0103: Module name "perlint-test" doesn't conform to snake_case naming style (invalid-name)
/Users/hughbrown/perlint-test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
/Users/hughbrown/perlint-test.py:3:0: C0116: Missing function or method docstring (missing-function-docstring)
/Users/hughbrown/perlint-test.py:8:8: C0103: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
/Users/hughbrown/perlint-test.py:11:16: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
/Users/hughbrown/perlint-test.py:11:16: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
/Users/hughbrown/perlint-test.py:11:16: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
Especially note line 11 where there is no invariant to hoist.
Also, it would be nice if the message identified which message is thought to be invariant.
Compiles to