"python -m modernize" Results Different Exit Codes than "python-modernize"
DavidMuller opened this issue · 3 comments
DavidMuller commented
Thanks for the work on this project!
I'm seeing some inconsistencies with exit codes depending on how python-modernize
is invoked on the command line...e.g. invoking the binary directly like python-modernize
yields a different error code than python -m modernize
:
$ python-modernize this-file-does-not-exist.py
etc.
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't open this-file-does-not-exist.py: [Errno 2] No such file or directory: 'this-file-does-not-exist.py'
$ echo $?
1
$ python -m modernize this-file-does-not-exist.py
etc.
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't open this-file-does-not-exist.py: [Errno 2] No such file or directory: 'this-file-does-not-exist.py'
$ echo $?
0
Any idea why this might be the case? I do not have the same experience with pip
- pip
apprears to return consistent status codes regardless of the execution style used:
$ pip this-should-fail
ERROR: unknown command "this-should-fail"
$ echo $?
1
$ python -m pip this-should-fail
ERROR: unknown command "this-should-fail"
$ echo $?
1
takluyver commented
If you find modernize.py installed on your computer and change the last line to sys.exit(main())
(and add the sys import), does it work?
DavidMuller commented
Yes -- that does the trick.
takluyver commented
Great! Do you want to send a PR?