flake8-executable icon indicating copy to clipboard operation
flake8-executable copied to clipboard

Check __name__ == ‘__main__’?

Open pkolbus opened this issue 5 years ago • 3 comments

Thanks for the great plugin.

What do you think about adding name == main checks vs the shebang line, under a couple of new EXEnnn IDs?

  • Found name == main but no shebang
  • Found shebang but no name == main

I frequently forget both the executable bit and the shebang when writing new command line scripts, so this would help. This also encourages better modularity and easier to package the script later as a setuptools entry_point. And finally. ensuring shebang lines aren’t added when they shouldn’t be.

If you agree, I can work on a PR.

pkolbus avatar Jan 22 '20 13:01 pkolbus

@pkolbus Sorry for the delayed response -- I missed the notification somehow. Yes, I think this would be helpful. Feel free to contribute a PR! Also, feel free to ping me if you don't see me responding.

xuhdev avatar Nov 23 '20 02:11 xuhdev

Thanks for the response. I'd actually forgotten about this issue and wrote a shell script for the executability checks, but will take another look at this plugin soon & either write the PR or close.

pkolbus avatar Nov 27 '20 20:11 pkolbus

It might be even better to check:

  • Found name == main but no shebang or no executable bit set
  • Found shebang executable bit set, but no name == main

Feel free to split the PR to address them separately, so it won't be too stressful.

xuhdev avatar Nov 28 '20 03:11 xuhdev