pnijhara / gitsome

Unnecessary generator PTC-W0015
Anti-pattern
Major
4 years ago4 years old
Unnecessary generator - rewrite as a list comprehension
296    if verbose:
297        return list(whichgen(command, path, verbose, exts))
298    else:
299        return list(absName for absName, _ in whichgen(command, path, verbose, exts))300
301
302# mainline
Unnecessary generator - rewrite as a list comprehension
 878    else:
 879        oneof = "" if num == 1 else "one of "
 880        tips = "Did you mean {}the following?".format(oneof)
 881        items = list(suggested.popitem(False) for _ in range(num)) 882        length = max(len(key) for key, _ in items) + 2
 883        alternatives = "\n".join(
 884            "    {: <{}} {}".format(key + ":", length, val) for key, val in items
Unnecessary generator - rewrite as a set comprehension
189    """Returns whether or not the string is a valid template."""
190    template = template() if callable(template) else template
191    try:
192        included_names = set(i[1] for i in xt.FORMATTER.parse(template))193    except ValueError:
194        return False
195    included_names.discard(None)
Unnecessary generator - rewrite as a set comprehension
 66
 67    # Selectively remove expected lines from the output
 68    for eline in expected.splitlines():
 69        resultlines = set(line for line in resultlines if not line.endswith(eline)) 70
 71    # Return True if no result lines remain
 72    return not bool(resultlines)
Unnecessary generator - rewrite as a dict comprehension
434        def __init__(self):
435            import nt
436
437            self._upperkeys = dict((k.upper(), k) for k in nt.environ)438
439        def _sync(self):
440            """ Ensure that the case sensitive map of the keys are