Giter Site home page Giter Site logo

Comments (10)

DimitriPapadopoulos avatar DimitriPapadopoulos commented on June 29, 2024 1

Indeed:

$ codespell -I non_existent_file
ERROR: cannot find ignore-words file: non_existent_file
[...]
$ echo $?
0
$ 
$ python -m codespell_lib -I non_existent_file
ERROR: cannot find ignore-words file: non_existent_file
[...]
$ echo $?
64
$ 

But the way, isn't $(python -m site --user-base)/bin in the PATH by default on most Linux distributions?

from codespell.

szepeviktor avatar szepeviktor commented on June 29, 2024

I install it in my user's home pip install --user and don't want to "$(python -m site --user-base)/bin/codespell"

from codespell.

szepeviktor avatar szepeviktor commented on June 29, 2024

But the way, isn't $(python -m site --user-base)/bin in the PATH by default on most Linux distributions?

Could be ...
But I like my computer to be extra simple.

from codespell.

DimitriPapadopoulos avatar DimitriPapadopoulos commented on June 29, 2024

The codespell executable $(python -m site --user-base)/bin/codespell looks like this:

from codespell_lib import _script_main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(_script_main())

File codespell_lib/__main__.py looks like this:

from ._codespell import _script_main

if __name__ == "__main__":
    _script_main()

Does changing the last line help?

if __name__ == "__main__":
    sys.exit(_script_main())

from codespell.

szepeviktor avatar szepeviktor commented on June 29, 2024

Yes.

from codespell.

DimitriPapadopoulos avatar DimitriPapadopoulos commented on June 29, 2024

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():

from codespell.

szepeviktor avatar szepeviktor commented on June 29, 2024

🤔

from codespell.

szepeviktor avatar szepeviktor commented on June 29, 2024

The only thing I can think of is: when codespell is used as a library it should not exit (terminate)

from codespell.

DimitriPapadopoulos avatar DimitriPapadopoulos commented on June 29, 2024

My wrong, it is (partially at least) documented:

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.

from codespell.

szepeviktor avatar szepeviktor commented on June 29, 2024

Done 🍏

from codespell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.