You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exit status is always 0 when started as a Python module #3156
Also, do you know if that's right thing to do? I cannot find definitive information in the relevant documentation, although some examples do call sys.exit():
main functions are often used to create command-line tools by specifying them as entry points for console scripts. When this is done, pip inserts the function call into a template script, where the return value of main is passed into sys.exit(). For example:
sys.exit(main())
Since the call to main is wrapped in sys.exit(), the expectation is that your function will return some value acceptable as an input to sys.exit(); typically, an integer or None (which is implicitly returned if your function does not have a return statement).
It's just that the above refers to the template script $(python -m site --user-base)/bin/codespell as far as I can tell, not to python -m. Also, I would have expected different wording such as "you MUST".
Can you please create a pull request that adds sys.exit()? I should be able to merge it rapidly - unlike my own pull requests.
Activity
szepeviktor commentedon Oct 17, 2023
I install it in my user's home
pip install --userand don't want to"$(python -m site --user-base)/bin/codespell"DimitriPapadopoulos commentedon Oct 17, 2023
Indeed:
But the way, isn't
$(python -m site --user-base)/binin thePATHby default on most Linux distributions?szepeviktor commentedon Oct 17, 2023
Could be ...
But I like my computer to be extra simple.
DimitriPapadopoulos commentedon Oct 17, 2023
The codespell executable
$(python -m site --user-base)/bin/codespelllooks like this:File
codespell_lib/__main__.pylooks like this:Does changing the last line help?
szepeviktor commentedon Oct 17, 2023
Yes.
DimitriPapadopoulos commentedon Oct 17, 2023
Also, do you know if that's right thing to do? I cannot find definitive information in the relevant documentation, although some examples do call
sys.exit():szepeviktor commentedon Oct 17, 2023
🤔
szepeviktor commentedon Oct 17, 2023
The only thing I can think of is: when codespell is used as a library it should not exit (terminate)
DimitriPapadopoulos commentedon Oct 17, 2023
My wrong, it is (partially at least) documented:
It's just that the above refers to the template script
$(python -m site --user-base)/bin/codespellas far as I can tell, not topython -m. Also, I would have expected different wording such as "you MUST".Can you please create a pull request that adds
sys.exit()? I should be able to merge it rapidly - unlike my own pull requests.szepeviktor commentedon Oct 17, 2023
Done 🍏