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

version 6.0.0 regression in parsing arguments (seen with flake8-import-order extension) #1751

Closed
zzzeek opened this issue Nov 23, 2022 · 1 comment
Labels

Comments

@zzzeek
Copy link

zzzeek commented Nov 23, 2022

how did you install flake8?

[classic@photon3 foo]$ virtualenv .venv
created virtual environment CPython3.10.0.final.0-64 in 284ms

[classic@photon3 foo]$ source .venv/bin/activate
(.venv) [classic@photon3 foo]$ pip install flake8 flake8_import_order
Collecting flake8
  Using cached flake8-6.0.0-py2.py3-none-any.whl (57 kB)
Collecting flake8_import_order
  Using cached flake8_import_order-0.18.1-py2.py3-none-any.whl (15 kB)

  ... install continues ...

Successfully installed flake8-6.0.0 flake8_import_order-0.18.1 mccabe-0.7.0 pycodestyle-2.10.0 pyflakes-3.0.0

unmodified output of flake8 --bug-report

$  flake8 --bug-report
Traceback (most recent call last):
  File "/home/classic/tmp/foo/.venv/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/main/application.py", line 186, in _run
    self.initialize(argv)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/main/application.py", line 165, in initialize
    self.plugins, self.options = parse_args(argv)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/options/parse_args.py", line 51, in parse_args
    option_manager.register_plugins(plugins)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/options/manager.py", line 259, in register_plugins
    add_options(self)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8_import_order/flake8_linter.py", line 44, in add_options
    register_opt(
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8_import_order/flake8_linter.py", line 98, in register_opt
    parser.add_option(*args, **kwargs)
  File "/home/classic/tmp/foo/.venv/lib/python3.10/site-packages/flake8/options/manager.py", line 281, in add_option
    self._current_group.add_argument(*option_args, **option_kwargs)
  File "/opt/python-3.10.0/lib/python3.10/argparse.py", line 1423, in add_argument
    raise ValueError('%r is not callable' % (type_func,))
ValueError: 'string' is not callable

describe the problem

argument parsing in flake8 is broken as of the just-released version 6.0.0; I took a look in flake8-import-order and it seems to be following flake8's extension API correctly in this regard

...

sample code

import string
import math

commands ran

$ flake8 test.py
@asottile
Copy link
Member

the 2-years-deprecated optparse support was removed in 6.0 -- please report to the plugin

@PyCQA PyCQA locked as resolved and limited conversation to collaborators Nov 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants