{ "version": 1, "entries": [ { "id": "mutable-default", "family": "refactoring", "shape": "mutable-default", "source": "Effective Python item 17", "effect": "the default is no longer built once at definition time", "lock": "calling the function twice returns an independent empty value", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "mutable-default" ] }, { "id": "magic-literal", "family": "refactoring", "shape": "magic-literal", "source": "Refactoring, chapter 7", "effect": "the value is named once at module level", "lock": "the module exposes the constant and the body refers to it", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "DYNAMIC_REACH" ], "min_assurance": 2, "frames": [ "magic-literal" ] }, { "id": "guard-clause", "family": "refactoring", "shape": "guard-clause", "source": "Refactoring, guard clause", "effect": "the body is no longer wrapped in one condition", "lock": "the function still returns the same value for the same input", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "guard-clause" ] }, { "id": "dead-import", "family": "refactoring", "shape": "dead-import", "source": "static property of the syntax tree", "effect": "the name is no longer bound and the module still imports", "lock": "the module imports cleanly and the name is gone", "refusals": [ "NO_SHAPE", "GENERATED_TARGET", "AMBIGUOUS_TARGET" ], "min_assurance": 1, "frames": [ "dead-import" ] }, { "id": "loop-comprehension", "family": "python_idiom", "shape": "loop-comprehension", "source": "the idiom of the language", "effect": "the list is built in one expression", "lock": "the list is equal to the one the loop built", "refusals": [ "NO_SHAPE", "DYNAMIC_REACH", "AMBIGUOUS_TARGET" ], "min_assurance": 2, "frames": [ "loop-comprehension" ] }, { "id": "concat-fstring", "family": "python_idiom", "shape": "concat-fstring", "source": "the idiom of the language", "effect": "the message is built by one formatted literal", "lock": "the produced string is byte equal to the concatenation", "refusals": [ "NO_SHAPE", "NOT_ASCII_TARGET", "AMBIGUOUS_TARGET" ], "min_assurance": 2, "frames": [ "concat-fstring" ] }, { "id": "add-assertion", "family": "methodology", "shape": "add-assertion", "source": "design by contract", "effect": "a caller passing the wrong type fails at the boundary", "lock": "the function raises AssertionError on a wrong argument", "refusals": [ "NO_SHAPE", "ASSERTION_REMOVED", "AMBIGUOUS_TARGET" ], "min_assurance": 2, "frames": [ "add-assertion" ] }, { "id": "unused-local", "family": "dead_code", "shape": "unused-local", "source": "witness fixtures/lab/registry.py tally", "effect": "a local value computed and never read", "lock": "the body no longer assigns the dead name", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "unused-local" ] }, { "id": "unreachable-code", "family": "dead_code", "shape": "unreachable-code", "source": "witness fixtures/lab/registry.py describe", "effect": "the statements that can never run are gone", "lock": "no statement survives after the return", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "unreachable-code" ] }, { "id": "empty-except", "family": "error_handling", "shape": "empty-except", "source": "witness fixtures/lab/registry.py ignore_late", "effect": "the exception is no longer swallowed", "lock": "the handler body is no longer a bare pass", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "empty-except" ] }, { "id": "bare-except", "family": "error_handling", "shape": "bare-except", "source": "witness fixtures/lab/registry.py quiet_read", "effect": "the handler names what it catches", "lock": "the except clause names an exception type", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "bare-except" ] }, { "id": "bool-prefix", "family": "simplification", "shape": "bool-prefix", "source": "witness fixtures/lab/registry.py is_empty", "effect": "the condition is returned instead of mapped onto a bool", "lock": "the function returns the condition it was mapping", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "bool-prefix" ] }, { "id": "len-zero", "family": "simplification", "shape": "len-zero", "source": "witness fixtures/lab/registry.py is_empty", "effect": "emptiness is tested by truthiness, not by length", "lock": "no comparison of a length with zero remains", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "len-zero" ] }, { "id": "bool-compare", "family": "simplification", "shape": "bool-compare", "source": "witness fixtures/lab/registry.py flag_text", "effect": "the value is tested, not compared to a bool literal", "lock": "no comparison with a bool literal remains", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "bool-compare" ] }, { "id": "dict-get", "family": "python_idiom", "shape": "dict-get", "source": "witness fixtures/lab/registry.py lookup", "effect": "the default comes from the mapping, not from a caught KeyError", "lock": "the mapping supplies the default without an exception", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "dict-get" ] }, { "id": "redundant-list", "family": "python_idiom", "shape": "redundant-list", "source": "witness fixtures/lab/registry.py names_of", "effect": "the comprehension is returned as it is", "lock": "the comprehension is returned without a list call", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "redundant-list" ] }, { "id": "str-of-string", "family": "python_idiom", "shape": "str-of-string", "source": "witness fixtures/lab/registry.py shout", "effect": "the value is used without a conversion it does not need", "lock": "the value is used without str around a string", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "str-of-string" ] }, { "id": "open-context", "family": "python_idiom", "shape": "open-context", "source": "witness fixtures/lab/registry.py read_notes", "effect": "the file is closed by the block that opened it", "lock": "the file is opened inside a with block", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "open-context" ] }, { "id": "range-len", "family": "python_idiom", "shape": "range-len", "source": "witness fixtures/lab/registry.py indexed", "effect": "the loop walks the items and their positions together", "lock": "the loop uses enumerate instead of range(len(...))", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "range-len" ] }, { "id": "dataclass-init", "family": "python_idiom", "shape": "dataclass-init", "source": "witness fixtures/lab/registry.py Record", "effect": "the constructor assignments are generated", "lock": "the class carries the dataclass decorator", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "dataclass-init" ] }, { "id": "none-compare", "family": "simplification", "shape": "none-compare", "source": "witness fixtures/lab/registry.py is_missing", "effect": "None is tested by identity instead of equality", "lock": "no comparison in the file uses an equality operator against None", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "none-compare" ] }, { "id": "dict-keys-in", "family": "python_idiom", "shape": "dict-keys-in", "source": "witness fixtures/lab/registry.py known", "effect": "membership is tested on the mapping instead of on its keys view", "lock": "no membership test in the file walks over a keys call", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "dict-keys-in" ] }, { "id": "useless-pass", "family": "dead_code", "shape": "useless-pass", "source": "witness fixtures/lab/registry.py drain", "effect": "the block loses a pass that has nothing left to stand in for", "lock": "no block with other statements still carries a pass", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "useless-pass" ] }, { "id": "no-else-return", "family": "simplification", "shape": "no-else-return", "source": "witness fixtures/lab/registry.py pick", "effect": "the else around a returned value is gone and the block is dedented", "lock": "no branch that returns is followed by an else", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "no-else-return" ] }, { "id": "sorted-first", "family": "python_idiom", "shape": "sorted-first", "source": "witness fixtures/lab/registry.py lowest", "effect": "the smallest value is read with min instead of a full sort", "lock": "no subscription reads index zero out of a sorted call", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "sorted-first" ] }, { "id": "dict-keys-loop", "family": "python_idiom", "shape": "dict-keys-loop", "source": "witness fixtures/lab/registry.py titles", "effect": "the loop iterates the mapping instead of the view over its keys", "lock": "no loop header in the file iterates a keys call", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "dict-keys-loop" ] }, { "id": "not-in-test", "family": "simplification", "shape": "not-in-test", "source": "witness fixtures/lab/registry.py absent", "effect": "the absence test reads as not in instead of not applied to in", "lock": "no unary not is applied to a membership test in the file", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "not-in-test" ] }, { "id": "redundant-slice", "family": "simplification", "shape": "redundant-slice", "source": "witness fixtures/lab/registry.py joined", "effect": "the value is read directly instead of sliced from end to end", "lock": "no subscription in the file slices a value from end to end", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "redundant-slice" ] }, { "id": "double-negation", "family": "simplification", "shape": "double-negation", "source": "witness fixtures/lab/registry.py visible", "effect": "the test reads positively instead of through two negations", "lock": "no expression in the file applies not to another not", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "double-negation" ] }, { "id": "chained-comparison", "family": "python_idiom", "shape": "chained-comparison", "source": "witness fixtures/lab/registry.py between", "effect": "the bounds are read as one chain instead of two joined comparisons", "lock": "no conjunction in the file joins two comparisons over the same middle value", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "chained-comparison" ] }, { "id": "redundant-open-mode", "family": "python_idiom", "shape": "redundant-open-mode", "source": "witness fixtures/lab/registry.py read_first", "effect": "the file is opened without repeating the mode it already has", "lock": "no open call in the file passes the read mode as an argument", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "redundant-open-mode" ] }, { "id": "identity-literal", "family": "correctness", "shape": "identity-literal", "source": "witness fixtures/lab/registry.py level_one", "effect": "the value is compared by equality instead of by identity", "lock": "no comparison in the file tests identity against a literal", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "identity-literal" ] }, { "id": "bool-in-condition", "family": "simplification", "shape": "bool-in-condition", "source": "witness fixtures/lab/registry.py shown", "effect": "the test reads the value instead of converting it first", "lock": "no if or while in the file tests a bool call", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "bool-in-condition" ] }, { "id": "lambda-assignment", "family": "python_idiom", "shape": "lambda-assignment", "source": "witness fixtures/lab/registry.py doubled", "effect": "the helper is a named function instead of a bound lambda", "lock": "no assignment in the file binds a lambda to a name", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "lambda-assignment" ] }, { "id": "bool-branch-assign", "family": "simplification", "shape": "bool-branch-assign", "source": "witness fixtures/lab/registry.py allowed", "effect": "the flag is assigned once from the condition", "lock": "no if with an else assigns only True and False to the same name", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "bool-branch-assign" ] }, { "id": "empty-container-call", "family": "python_idiom", "shape": "empty-container-call", "source": "witness fixtures/lab/registry.py empty_book", "effect": "the empty container is written as a literal instead of a call", "lock": "no empty list, dict or tuple is built by a call in the file", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "empty-container-call" ] }, { "id": "equality-with-empty-list", "family": "simplification", "shape": "equality-with-empty-list", "source": "witness fixtures/lab/registry.py no_items", "effect": "emptiness is read from the value instead of from an empty literal", "lock": "no comparison in the file is made against an empty list", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "equality-with-empty-list" ] }, { "id": "type-equality", "family": "correctness", "shape": "type-equality", "source": "witness fixtures/lab/registry.py is_text", "effect": "the type question is asked with isinstance, which accepts subclasses", "lock": "no comparison in the file calls type on its left side", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "type-equality" ] }, { "id": "lambda-wrapper", "family": "python_idiom", "shape": "lambda-wrapper", "source": "witness fixtures/lab/registry.py ranked", "effect": "the function is passed itself instead of wrapped in a lambda", "lock": "no lambda in the file only forwards its argument to a call", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "lambda-wrapper" ] }, { "id": "list-in-aggregator", "family": "python_idiom", "shape": "list-in-aggregator", "source": "witness fixtures/lab/registry.py total_lengths", "effect": "the aggregator reads the generator instead of a list built for the moment", "lock": "no sum, min or max in the file is given a comprehension inside square brackets", "refusals": [ "NO_SHAPE", "AMBIGUOUS_TARGET", "NO_EDIT", "ASSERTION_REMOVED" ], "min_assurance": 2, "frames": [ "list-in-aggregator" ] } ] }