运行 薄片 8。为什么我会收到此错误。线程与它有什么关系?

Running flake8. Why I'm getting this error. What does threads have to do with it?

在这里,我正在尝试 运行 flake8 在我的项目中。 flake8 myproject 但它给了我

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.8/multiprocessing/pool.py", line 576, in _handle_results
    task = get()
  File "/usr/lib/python3.8/multiprocessing/connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
  File "/home/greenbull/PycharmProjects/QazRiot/venv/lib/python3.8/site-packages/isort/exceptions.py", line 163, in __init__
    self._format_option(name, **option) for name, option in unsupported_settings.items()
AttributeError: 'str' object has no attribute 'items'

你能帮忙解决这个问题吗?

这是两件事的结合:

  • isort 设置了一些不受支持的选项(您可能可以使用 isort --help 触发它)
  • isort 的异常不是 pickle 安全的(isortplease report it there 中的错误)

这里是关于酸洗错误的最小再现:

>>> from isort.exceptions import UnsupportedSettings
>>> import pickle
>>> e = UnsupportedSettings({'foo': {'value': 'bar', 'source': 'wat'}})
>>> e
UnsupportedSettings("isort was provided settings that it doesn't support:\n\n\t- foo = bar  (source: 'wat')\n\nFor a complete and up-to-date listing of supported settings see: https://pycqa.github.io/isort/docs/configuration/options.\n")
>>> pickle.loads(pickle.dumps(e))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/y/venv/lib/python3.8/site-packages/isort/exceptions.py", line 163, in __init__
    self._format_option(name, **option) for name, option in unsupported_settings.items()
AttributeError: 'str' object has no attribute 'items'

flake8 为 运行 使用多重处理(并且多重处理使用 pickle 发送参数),这就是触发它的原因。您可以通过 运行 flake8 -j1

解决此问题(至少显示原始错误消息)

免责声明:我是当前的 flake8 维护者