Skip to content

Commit ef3c5cb

Browse files
authored
Deprecate optparse in favor of argparse (#499)
* Deprecate optparse in favor of argparse * Support '-V' as an alias for '--version'
1 parent 598eb16 commit ef3c5cb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pyflakes/api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,18 @@ def _get_version():
193193

194194
def main(prog=None, args=None):
195195
"""Entry point for the script "pyflakes"."""
196-
import optparse
196+
import argparse
197197

198198
# Handle "Keyboard Interrupt" and "Broken pipe" gracefully
199199
_exitOnSignal('SIGINT', '... stopped')
200200
_exitOnSignal('SIGPIPE', 1)
201201

202-
parser = optparse.OptionParser(prog=prog, version=_get_version())
203-
(__, args) = parser.parse_args(args=args)
202+
parser = argparse.ArgumentParser(prog=prog,
203+
description='Check Python source files for errors')
204+
parser.add_argument('-V', '--version', action='version', version=_get_version())
205+
parser.add_argument('path', nargs='*',
206+
help='Path(s) of Python file(s) to check. STDIN if not given.')
207+
args = parser.parse_args(args=args).path
204208
reporter = modReporter._makeDefaultReporter()
205209
if args:
206210
warnings = checkRecursive(args, reporter)

0 commit comments

Comments
 (0)