-1

After upgrading to flake8 v6.0.0, I tried running the command flake8 at the project level. However, I receive this error in the console:

Traceback (most recent call last):
  File "env/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/main/application.py", line 186, in _run
    self.initialize(argv)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/main/application.py", line 165, in initialize
    self.plugins, self.options = parse_args(argv)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/options/parse_args.py", line 51, in parse_args
    option_manager.register_plugins(plugins)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/options/manager.py", line 259, in register_plugins
    add_options(self)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8_quotes/__init__.py", line 100, in add_options
    cls._register_opt(parser, '--quotes', action='store',
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8_quotes/__init__.py", line 90, in _register_opt
    parser.add_option(*args, **kwargs)
  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/options/manager.py", line 281, in add_option
    self._current_group.add_argument(*option_args, **option_kwargs)
  File "/Users/gree030/.pyenv/versions/3.8.15/lib/python3.8/argparse.py", line 1373, in add_argument
    raise ValueError('%r is not callable' % (type_func,))
ValueError: 'choice' is not callable


What I have tried

  • Downgrading to 5.0.4, removes the error. However, I would like to use 6.0.0
  • $ flake myproject
  • $ env/bin/flake8 myproject
  • $ python3.8 -m flake8
  • Reading the documentation

setup.cfg File

# Black-compatible configurations
[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88

[flake8]
ignore = D413, E203, E266, E501, E711, W503, F401, F403
max-line-length = 100
max-complexity = 18
select = B,C,E,F,W,T4,B9
application-import-names = myproject,tests
import-order-style = google
per-file-ignores = __init__.py:F401
exclude = tests/integration/.env.shadow, env
require-plugins =
    flake8-import-single


[pylint]
max-line-length = 88

[pylint.messages_control]
disable = C0330, C0326

Directory Structure

For reference, env is my python virtual environment. I am also using Python 3.8

├── Dockerfile
├── Makefile
├── env
│   ├── bin
│   ├── include
│   ├── lib
│   ...
├── myproject
│   ├── __init__.py
│     ...
├── requirements-dev.txt
├── requirements.txt
├── setup.cfg

Khalil
  • 175
  • 2
  • 8
  • https://github.com/zheller/flake8-quotes/issues/110 - you have flake8-quotes plugin installed which is not compatible with flake8 6.. Remove or upgrade ? – rasjani Mar 10 '23 at 12:56
  • I've seen that issue before as well. No, I'm not using flake8-quotes plugin – Khalil Mar 10 '23 at 13:09
  • `/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8_quotes/__init__.py` <--- That really really *REALLY* *REALLY* Looks like you have it installed .. As i said: either remove it or upgrade .. That is the root of your issue – rasjani Mar 10 '23 at 13:16

1 Answers1

2

you have flake8-quotes installed -- specifically a version which uses the deprecated 'choice' optparse type

this is apparent from this line in your stacktrace:

File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8_quotes/__init__.py", line 90, in _register_opt

you have a few options:

  1. uninstall flake8-quotes pip uninstall flake8-quotes
  2. upgrade to a version which is compatible with flake8 6.x pip install 'flake8-quotes>=3.3.2'

disclaimer: I maintain flake8

anthony sottile
  • 61,815
  • 15
  • 148
  • 207