Clean up set and file usage in get_all_imports

- Move logic that doesn't need to be inside of file context managers
  outside
- Remove redundant `set` and `list` function calls
This commit is contained in:
Jon Banafato 2017-10-20 23:43:45 -04:00
parent 7afbcb4b16
commit aae6c61f09

View File

@ -114,13 +114,14 @@ def get_all_imports(
cleaned_name, _, _ = name.partition('.')
imports.add(cleaned_name)
packages = set(imports) - set(set(candidates) & set(imports))
packages = imports - (set(candidates) & imports)
logging.debug('Found packages: {0}'.format(packages))
with open(join("stdlib"), "r") as f:
data = [x.strip() for x in f.readlines()]
data = [x for x in data if x not in py2_exclude] if py2 else data
return list(set(packages) - set(data))
data = {x.strip() for x in f}
data = {x for x in data if x not in py2_exclude} if py2 else data
return list(packages - data)
def filter_line(l):