Skip to content

Conversation

@asottile
Copy link
Member

been deprecated for 2+ years, time to remove it -- should make reworking this easier


here's the error messages that you'll see as well as how to fix things:

you have %default (optparse type) => %(default)s

error:

$ flake8 --help
...
  File "/usr/lib/python3.10/argparse.py", line 642, in _expand_help
    return self._get_help_string(action) % params
TypeError: %d format: a real number is required, not dict

you have type='callback', not really any full replacement

error:

$ flake8 t.py
...
  File "/home/asottile/workspace/flake8/a.py", line 7, in add_options
    parser.add_option(
  File "/home/asottile/workspace/flake8/src/flake8/options/manager.py", line 278, in add_option
    option = Option(*args, **kwargs)
TypeError: Option.__init__() got an unexpected keyword argument 'callback'

you have type='int' => type=int (or other types)

$ flake8 t.py
...
  File "/home/asottile/workspace/flake8/a.py", line 7, in add_options
    parser.add_option("--foo", type="int")
  File "/home/asottile/workspace/flake8/src/flake8/options/manager.py", line 281, in add_option
    self._current_group.add_argument(*option_args, **option_kwargs)
  File "/usr/lib/python3.10/argparse.py", line 1440, in add_argument
    raise ValueError('%r is not callable' % (type_func,))
ValueError: 'int' is not callable

@asottile asottile merged commit 16c371d into main Nov 16, 2022
@asottile asottile deleted the remove-optparse branch November 16, 2022 00:10
@asottile asottile added this to the 6.0.0 milestone Nov 23, 2022
xi added a commit to xi/flake8-copyright that referenced this pull request Nov 30, 2022
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

Successfully merging this pull request may close these issues.

2 participants