MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
186 stars 19 forks source link

[Error] Not working with flake8==7.0.0 and Python 3.11.7 #191

Open Danipulok opened 9 months ago

Danipulok commented 9 months ago

Installed versions:

flake8==7.0.0
flake8-simplify==0.21.0

Error:

$ flake8
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8\checker.py", line 83, in _mp_run
    ).run_checks()
      ^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8\checker.py", line 526, in run_checks
    self.run_ast_checks()
  File "D:\app\.venv11\Lib\site-packages\flake8\checker.py", line 428, in run_ast_checks
    for line_number, offset, text, _ in runner:
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\__init__.py", line 161, in run
    visitor.visit(self._tree)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\ast.py", line 426, in generic_visit
    self.visit(item)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\__init__.py", line 146, in visit_ClassDef
    self.generic_visit(node)
  File "C:\Program Files\Python311\Lib\ast.py", line 426, in generic_visit
    self.visit(item)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\ast.py", line 426, in generic_visit
    self.visit(item)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\__init__.py", line 89, in visit_Expr
    self.generic_visit(node)
  File "C:\Program Files\Python311\Lib\ast.py", line 428, in generic_visit
    self.visit(value)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\__init__.py", line 81, in visit_Call
    self.generic_visit(node)
  File "C:\Program Files\Python311\Lib\ast.py", line 426, in generic_visit
    self.visit(item)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\__init__.py", line 81, in visit_Call
    self.generic_visit(node)
  File "C:\Program Files\Python311\Lib\ast.py", line 426, in generic_visit
    self.visit(item)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\ast.py", line 428, in generic_visit
    self.visit(value)
  File "C:\Program Files\Python311\Lib\ast.py", line 418, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\__init__.py", line 77, in visit_Call
    self.errors += get_sim905(node)
                   ^^^^^^^^^^^^^^^^
  File "D:\app\.venv11\Lib\site-packages\flake8_simplify\rules\ast_call.py", line 111, in get_sim905
    expected = json.dumps(value.split())
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\json\encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\json\encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\json\encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\app\.venv11\Scripts\flake8.exe\__main__.py", line 7, in <module>
  File "D:\app\.venv11\Lib\site-packages\flake8\main\cli.py", line 23, in main
    app.run(argv)
  File "D:\app\.venv11\Lib\site-packages\flake8\main\application.py", line 198, in run
    self._run(argv)
  File "D:\app\.venv11\Lib\site-packages\flake8\main\application.py", line 187, in _run
    self.run_checks()
  File "D:\app\.venv11\Lib\site-packages\flake8\main\application.py", line 103, in run_checks
    self.file_checker_manager.run()
  File "D:\app\.venv11\Lib\site-packages\flake8\checker.py", line 236, in run
    self.run_parallel()
  File "D:\app\.venv11\Lib\site-packages\flake8\checker.py", line 205, in run_parallel
    self.results = list(pool.imap_unordered(_mp_run, self.filenames))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\multiprocessing\pool.py", line 873, in next
    raise value
TypeError: Object of type bytes is not JSON serializable

OS info:

OS: Windows
OS Release: 10
OS Version: 10.0.19045
Architecture: AMD64
Processor: AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD
Python Version: 3.11.7