973 # between branches and tags. By ignoring refnames without digits, we
974 # filter out many common branch names like "release" and
975 # "stabilization", as well as "HEAD" and "master".
976 tags = set([r for r in refs if re.search(r'\d', r)]) 977 if verbose:
978 print("discarding '%s', no digits" % ",".join(refs-tags))
979 if verbose:
964 # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
965 # just "foo-1.0". If we see a "tag: " prefix, prefer those.
966 TAG = "tag: "
967 tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) 968 if not tags:
969 # Either we're using git < 1.8.3, or there really are no tags. We use
970 # a heuristic: assume all version tags have a digit. The old git %d
960 if verbose:
961 print("keywords are unexpanded, not using")
962 raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
963 refs = set([r.strip() for r in refnames.strip("()").split(",")]) 964 # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
965 # just "foo-1.0". If we see a "tag: " prefix, prefer those.
966 TAG = "tag: "
Although there is nothing syntactically wrong with this code, it is hard to read and can be simplified to a set comprehension. Using set comprehension is more performant since there is no need to create a transient list.
mapping = set([num for num in my_magic_nums])
mapping = {num for num in my_magic_nums}