Skip to content

Check __name__ == ‘__main__’? #2

Open

Description

@pkolbus

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.

Activity

  1. xuhdev commented on Nov 23, 2020

    @xuhdev
    Owner

    @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.

  2. pkolbus commented on Nov 27, 2020

    @pkolbus
    Author

    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.

  3. xuhdev commented on Nov 28, 2020

    @xuhdev
    Owner

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions