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

switch from optparse to argparse #24

Closed
nikolas opened this issue Jun 17, 2015 · 7 comments
Closed

switch from optparse to argparse #24

nikolas opened this issue Jun 17, 2015 · 7 comments

Comments

@nikolas
Copy link
Contributor

nikolas commented Jun 17, 2015

I noticed behave.py uses optparse.. I think we should switch to argparse as it's better supported.

From https://docs.python.org/2/library/optparse.html

Deprecated since version 2.7: The optparse module is deprecated and will not be developed further; development will continue with the argparse module.

I'll try to make a PR for this at some point, unless you get to it before I do.

@bittner
Copy link
Collaborator

bittner commented Jun 19, 2015

@nikolas, just a few hints to get you started, if you don't mind:

  • Be inspired by code I wrote for django-organice (saves you some trouble-shooting) ... (EDIT, 2016/02: obsolete in the meantime)
  • ... though a try-except approach may be more pythonic, e.g.
try:
    from argparse import ArgumentParser  # New since Python 2.7
    parser = ArgumentParser()
except ImportError:
    from optparse import OptionParser  # Deprecated since Python 2.7
    parser = OptionParser()
    parser.add_argument = parser.add_option  # use add_argument in any case

parser.add_argument('foo', help='foo does bar and baz')

# ... and a similar try-except block for the actual parsing and evaluation

@nikolas
Copy link
Contributor Author

nikolas commented Jun 19, 2015

@bittner thanks for the tips!

@bittner
Copy link
Collaborator

bittner commented Jun 21, 2015

Another note: I just see, until Django 1.7 optparse's make_option is used for the option_list. The implementation of our management command pretty much depends on that. Django 1.8 makes the switch finally to argparse. I fear an implementation change on our side will probably have to follow their approach and may need to consider the Django version in use.

See Also

@oiwn
Copy link

oiwn commented Feb 5, 2016

This deprecation warning is a bit annoying. Any news?

@bittner
Copy link
Collaborator

bittner commented Feb 5, 2016

This affects

Anything else?

What is the exact deprecation warning, and when does it occur? (I don't notice any with Python 3.4 and Django 1.8)

@bittner
Copy link
Collaborator

bittner commented Mar 14, 2016

@mixxorz We should address this deprecation warning now that we're under the hood of the behave organization. As more and more developers start using Django 1.9 this issue becomes more visible.

@bittner
Copy link
Collaborator

bittner commented Mar 14, 2016

Closing this issue in favor of issue 2 in behave/behave-django. Please follow-up there.

@bittner bittner closed this as completed Mar 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants