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

remove optparse support #1739

Merged
merged 1 commit into from Nov 16, 2022
Merged

remove optparse support #1739

merged 1 commit into from Nov 16, 2022

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.

None yet

1 participant