diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-10-10 05:15:57 -0700 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-10-10 05:15:57 -0700 |
commit | 488818eeb62756cd8e22114dbca9851bd3e55e53 (patch) | |
tree | f27d23eba41c5e940853b5f6e1bdf69fdc143b65 | |
parent | 296c80d1f25dc48f9dc5643de86ccf5461f9241d (diff) | |
download | psycopg2-488818eeb62756cd8e22114dbca9851bd3e55e53.tar.gz |
Replace deprecated optparse usage with argparse
Per https://docs.python.org/3/library/optparse.html
> Deprecated since version 3.2: The optparse module is deprecated and
> will not be developed further; development will continue with the
> argparse module.
-rwxr-xr-x | scripts/refcounter.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/scripts/refcounter.py b/scripts/refcounter.py index f41dc21..a5f62d0 100755 --- a/scripts/refcounter.py +++ b/scripts/refcounter.py @@ -19,6 +19,7 @@ script exits with error 1. # License for more details. from __future__ import print_function +import argparse import gc import sys import difflib @@ -62,19 +63,16 @@ def main(): def parse_args(): - import optparse - - parser = optparse.OptionParser(description=__doc__) - parser.add_option('--nruns', type='int', metavar="N", default=3, - help="number of test suite runs [default: %default]") - parser.add_option('--suite', metavar="NAME", + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--nruns', type=int, metavar="N", default=3, + help="number of test suite runs [default: %(default)d]") + parser.add_argument('--suite', metavar="NAME", help="the test suite to run (e.g. 'test_cursor'). [default: all]") - parser.add_option('--objs', metavar="TYPE", + parser.add_argument('--objs', metavar="TYPE", help="in case of leaks, print a report of object TYPE " "(support still incomplete)") - opt, args = parser.parse_args() - return opt + return parser.parse_args() def dump(i, opt): |