SublimeLinter / SublimeLinter-flake8

SublimeLinter plugin for python, using flake8.
MIT License
184 stars 28 forks source link

AttributeError: 'int' object has no attribute 'rstrip' #121

Closed ataylor32 closed 3 years ago

ataylor32 commented 3 years ago

Certain flake8 issues cause this to appear at the bottom of Sublime Text:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/checker.py", line 478, in run_ast_checks
    ast = self.processor.build_ast()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/processor.py", line 225, in build_ast
    return ast.parse("".join(self.lines))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    import
          ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/main/application.py", line 363, in run
    self._run(argv)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/main/application.py", line 351, in _run
    self.run_checks()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/main/application.py", line 264, in run_checks
    self.file_checker_manager.run()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/checker.py", line 323, in run
    self.run_serial()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/checker.py", line 307, in run_serial
    checker.run_checks()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/checker.py", line 589, in run_checks
    self.run_ast_checks()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/checker.py", line 480, in run_ast_checks
    row, column = self._extract_syntax_information(e)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flake8/checker.py", line 465, in _extract_syntax_information
    lines = physical_line.rstrip("\n").split("\n")
AttributeError: 'int' object has no attribute 'rstrip'
blalor commented 3 years ago

I think that's this issue: https://github.com/PyCQA/flake8/issues/1372 (I'm having the same problem).

blalor commented 3 years ago

I ended up having to reinstall flake8 via homebrew (brew reinstall flake8); for some reason homebrew thought 4.0.1 was installed, but 3.9.2 was actually installed. 🤨

ataylor32 commented 3 years ago

@blalor Yes, upgrading flake8 solved it. Thanks!