zestyping / star-destroyer

Eliminates "import *" from your modules.
Apache License 2.0
37 stars 2 forks source link

Crashes when running on invalid files #4

Closed sils closed 8 years ago

sils commented 8 years ago

We have a test file with invalid python syntax somewhere so I can't run this as there's no way to ignore the file and apparently star destroyer doesn't deal with exceptions.

Traceback (most recent call last):
  File "/usr/lib64/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/lasse/venvs/def/lib/python3.5/site-packages/star_destroyer.py", line 374, in <module>
    modules, import_map, usage_map = scan(root_path)
  File "/home/lasse/venvs/def/lib/python3.5/site-packages/star_destroyer.py", line 317, in scan
    modules = list(get_modules(root_path))
  File "/home/lasse/venvs/def/lib/python3.5/site-packages/star_destroyer.py", line 314, in get_modules
    yield (pkgpath, modpath, path, ast.parse(open(path).read()))
  File "/usr/lib64/python3.5/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    The Zen of Python, by Tim Peters
          ^
SyntaxError: invalid syntax
sils commented 8 years ago

related to #3