JBKahn / flake8-debugger

flake8 debug statement checker
MIT License
41 stars 10 forks source link

SyntaxError: unexpected EOF while parsing #5

Closed The-Compiler closed 6 years ago

The-Compiler commented 8 years ago

Hey,

I'm still on flake8 2.6.2 since some plugins I need haven't been ported yet. Do you still intend to support it?

I updated flake8-debugger to 2.0.0 and get this:

Traceback (most recent call last):
  File "/usr/lib64/python3.5/runpy.py", line 184, 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/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8/__main__.py", line 4, in <module>
    main()
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8/main.py", line 36, in main
    report = flake8_style.check_files()
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8/engine.py", line 181, in check_files
    return self._retry_serial(self._styleguide.check_files, paths=paths)
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8/engine.py", line 172, in _retry_serial
    return func(*args, **kwargs)
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/pycodestyle.py", line 1875, in check_files
    self.input_dir(path)
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/pycodestyle.py", line 1911, in input_dir
    runner(os.path.join(root, filename))
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8/engine.py", line 126, in input_file
    return fchecker.check_all(expected=expected, line_offset=line_offset)
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/pycodestyle.py", line 1634, in check_all
    self.check_logical()
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/pycodestyle.py", line 1534, in check_logical
    for offset, text in self.run_check(check, argument_names) or ():
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8_debugger.py", line 88, in debugger_usage
    for import_type, item_imported, item_alias, trace_method, trace_alias in generator:
  File "/home/florian/proj/qutebrowser/git/.tox/flake8/lib/python3.5/site-packages/flake8_debugger.py", line 44, in check_for_debugger_import
    for node in ast.walk(ast.parse(logical_line)):
  File "/usr/lib64/python3.5/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    if __name__ == 'xxxxxxxx':
                             ^
SyntaxError: unexpected EOF while parsing
The-Compiler commented 8 years ago

I have no idea where the "if __name__ == 'xxxxxxxx':" is coming from, it's certainly not something in my code.

JBKahn commented 8 years ago

Nor mine. I just pushed a new version I'll do some more testing today. I see you're on Python 3.5, I'll make sure to explicitly test it.

On Tue, Sep 20, 2016, 3:38 AM Florian Bruhin notifications@github.com wrote:

I have no idea where the "if name == 'xxxxxxxx':" is coming from, it's certainly not something in my code.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JBKahn/flake8-debugger/issues/5#issuecomment-248227052, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiBvfQsjO3ANaKrOi-t8EX49YgVxqojks5qr42CgaJpZM4KBUA9 .

The-Compiler commented 8 years ago

FWIW I added a print(logical_line) at the top of check_for_debugger_import and I get this:

"""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
import sys
import qutebrowser.qutebrowser
if __name__ == 'xxxxxxxx':

which looks like a mangled (by flake8?) version of qutebrowser/__main__.py.

JBKahn commented 8 years ago

Hmm is that the latest version? What if you downgrade or upgrade the dependency?

On Tue, Sep 20, 2016, 7:54 AM Florian Bruhin notifications@github.com wrote:

FWIW I added a print(logical_line) at the top of check_for_debugger_import and I get this:

"""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""import sysimport qutebrowser.qutebrowserif name == 'xxxxxxxx':

which looks like a mangled (by flake8?) version of qutebrowser/main.py https://github.com/The-Compiler/qutebrowser/blob/master/qutebrowser/__main__.py .

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/JBKahn/flake8-debugger/issues/5#issuecomment-248279862, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiBvSQwUS1r9zV-Lpo6my9gbOCGbY9aks5qr8l7gaJpZM4KBUA9 .

JBKahn commented 8 years ago

Well it does mangle all text during parsing, but perhaps there's something about parsing the conditional where it's trying to parse it in isolation and throwing an error since it's just a condition and a colon. That shouldn't happen...

JBKahn commented 8 years ago

Just on my way to my office now, seems like it could be an issue with my usage of ast. If i can reproduce this then I'll probably pull the version and fix it over the next few days.

idgserpro commented 8 years ago

Same error with python 2.7.

JBKahn commented 8 years ago

Ya, I rolled back the change, I'll fix it asap.

JBKahn commented 6 years ago

Finally circled back, fixed and released a new version.