Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with flake8 #31

Open
NastasiaSaby opened this issue Jan 24, 2022 · 4 comments
Open

Bug with flake8 #31

NastasiaSaby opened this issue Jan 24, 2022 · 4 comments

Comments

@NastasiaSaby
Copy link

NastasiaSaby commented Jan 24, 2022

I have a bug when trying to use flake8.

Here is my code:

%pip install flake8 pycodestyle_magic
%load_ext pycodestyle_magic
%flake8_on
a=1

When doing that, I have this error:

Error in callback <bound method VarWatcher.auto_run_flake8 of <pycodestyle_magic.VarWatcher object at 0x7feb812c7d90>> (for post_run_cell):
AttributeError: '_io.StringIO' object has no attribute 'buffer'

Technical details:

  • pycodestyle==2.8.0
  • pycodestyle-magic==0.5
  • Python version = 3.8.8
  • flake8==4.0.1

Is there a bug or something like that?

@nicolas-chan-42
Copy link

nicolas-chan-42 commented Feb 14, 2022

Similar situation here.

The following code is fine.

%%flake8
from colorama import init, Fore

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.edge.service import Service
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.ui import WebDriverWait

But with the addition of one line of comment:

%%flake8
from colorama import init, Fore

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.edge.service import Service
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.ui import WebDriverWait
#from selenium.common.exceptions import NoSuchElementException, ElementClickInterceptedException

An AttributeError is raised.

AttributeError: '_io.StringIO' object has no attribute 'buffer'

If %flake8_on is used, the same issue occurs.
However, %pycodestyle_on or %%pycodestyle do not have such issue and work normally.

Installed packages (sorted by relevance in my opinion):

  • python==3.10.2
  • pycodestyle==2.8.0
  • pycodestyle_magic==0.5
  • flake8==4.0.1
  • ipython==8.0.1
  • ipykernel==6.9.0
  • ipython-genutils==0.2.0
  • ipywidgets==7.6.5
  • notebook==6.4.8
  • nbclient==0.5.10
  • nbformat==5.1.3
  • colorama==0.4.4
  • selenium==4.1.0

Please look into the issue. Thank you.

@nicolas-chan-42
Copy link

The following is a rough traceback (the code is run on my work computer and I have to retype it here):

Input in [2], <module>
----> 1 get_ipython.run_cell_magic('flake8', '', ...)

File ~\...\site-packages\IPython\core\interactiveshell.py:2257, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
-> 2257     result = fn(*args, **kwargs)

File ~\...\site-packages\pycodestyle_magic.py:218, in flake8(line, cell, auto)
-> 218     _ = flake.check_files([f.name])

File ~\...\site-packages\flake8\api\legacy.py:110, in StyleGuide.check_files(self, paths)
-> 110 self._application.report_errors()

File ~\...\site-packages\flake8\main\application.py:309, in Application.report_errors(self)
-> 309 results = self.file_checker_manager.report()

File ~\...\site-packages\flake8\checker.py:249, in Manager.report(self)
-> 249         results_reported += self._handle_results(filename, results)

File ~\...\site-packages\flake8\checker.py:155, in Manager._handle_results(self, filename, results)
-> 155     reported_results_count += style_guide.handle_error(...)

File ~\...\site-packages\flake8\style_guide.py:429, in StyleGuideManager.handle_error(self, ...)
-> 429 return guide.handle_error(...)

File ~\...\site-packages\flake8\style_guide.py:581, in StyleGuide.handle_error(self, ...)
-> 581 self.formatter.handle(error)

File ~\...\site-packages\flake8\formatting\base.py:100, in BaseFormatter.handle(self, error)
-> 100 self.write(line, source)

File ~\...\site-packages\flake8\formatting\base.py:203, in BaseFormatter.write(self, line, source)
-> 203     self._write(line)

File ~\...\site-packages\flake8\formatting\base.py:187, in BaseFormatter._write(self, output)
-> 187     sys.stdout.buffer.write(output.encode() + self.newline.encode())

AttributeError: '_io.StringIO' object has no attribute 'buffer'

@trenton3983
Copy link

I installed flake8 v3.9.2 to work around the issue.

@psychemedia
Copy link

Related issue on flake8 - I think the magic needs updating to address this: PyCQA/flake8#1419

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants