Add python3 script shebang lint #12972

pull ken2812221 wants to merge 2 commits into bitcoin:master from ken2812221:explicit_python3 changing 2 files +13 −3
  1. ken2812221 commented at 3:43 AM on April 13, 2018: contributor

    base58.py can executed by python3

  2. fanquake added the label Scripts and tools on Apr 13, 2018
  3. Empact commented at 10:31 AM on April 13, 2018: member

    Good candidate for a lint?

  4. MarcoFalke commented at 1:37 PM on April 13, 2018: member

    To the best of my knowledge, the script is outdated and won't produce test vectors in the current format. Since you are touching this file, might as well fix this in one go?

  5. MarcoFalke commented at 1:47 PM on April 13, 2018: member

    Also the readme should be updated to reflect the new names, i.e. "src/test/data/key_io_valid.json" and "src/test/data/key_io_invalid.json"

  6. practicalswift commented at 2:00 PM on April 13, 2018: contributor

    @Empact The linter you're thinking about would check that all *.py files start with #!/usr/bin/env python3? Anything more?

  7. ken2812221 force-pushed on Apr 13, 2018
  8. ken2812221 commented at 2:26 PM on April 13, 2018: contributor

    @MarcoFalke since we don't generate testdata dynamically, should we delete this testgen directory?

  9. ken2812221 commented at 2:36 PM on April 13, 2018: contributor

    I don't know how to deal with contrib/devtools/test-security-check.py, it seems outdated, and not python3 code

  10. jnewbery commented at 2:56 PM on April 13, 2018: member

    Concept ACK adding the linter, however it should only return an error if there's a python or python2 shebang. It's fine to have no shebang if the module is not intended to be run as a standalone executable.

    I don't think we should add shebangs to modules which aren't intended to be run as standalone executables.

    test-security-check.py was overlooked in #11881. You can convert it to Python3 with the following commit: https://github.com/jnewbery/bitcoin/commit/35cb5dafdd5d08ed536971ae9401c56f98b4f421

  11. practicalswift commented at 3:01 PM on April 13, 2018: contributor

    @ken2812221 What about this linter?

    #!/bin/bash
    
    EXIT_CODE=0
    for PYTHON_FILE in $(git ls-files -- "*.py"); do
        if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
              $(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
            echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE}"
            EXIT_CODE=1
        fi
    done
    exit ${EXIT_CODE}
    
  12. ken2812221 force-pushed on Apr 13, 2018
  13. ken2812221 force-pushed on Apr 13, 2018
  14. ken2812221 commented at 3:31 PM on April 13, 2018: contributor

    @practicalswift Seems your lint is flexible

  15. ken2812221 commented at 4:20 PM on April 13, 2018: contributor

    @jnewbery thanks

  16. practicalswift commented at 4:24 PM on April 13, 2018: contributor

    utACK 294e59675bf326eb0e81a6685410f25df5619be4

  17. in contrib/testgen/base58.py:1 in 294e59675b outdated
       0 | @@ -1,3 +1,4 @@
       1 | +#!/usr/bin/env python3
    


    jnewbery commented at 5:24 PM on April 13, 2018:

    I still don't think base58.py requires a shebang. It's not executable:

    → ls -l contrib/testgen/base58.py
    -rw-rw-r-- 1 ubuntu ubuntu 3092 Apr 13 14:37 contrib/testgen/base58.py
    
  18. in contrib/devtools/lint-python-shebang.sh:7 in 294e59675b outdated
       0 | @@ -0,0 +1,11 @@
       1 | +#!/bin/bash
       2 | +
       3 | +EXIT_CODE=0
       4 | +for PYTHON_FILE in $(git ls-files -- "*.py"); do
       5 | +    if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
       6 | +          $(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
       7 | +        echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE}"
    


    jnewbery commented at 5:24 PM on April 13, 2018:

    Comment could be clearer. Something like "Shebang must use python3 (not python or python2)"

  19. add lint tool to check python3 shebang 958bf40489
  20. [contrib] convert test-security-check to python3 2bff472992
  21. ken2812221 force-pushed on Apr 13, 2018
  22. ken2812221 renamed this:
    trivial: Use python3 explicitly
    Add python3 script shebang lint
    on Apr 13, 2018
  23. practicalswift commented at 5:13 AM on April 14, 2018: contributor

    utACK 2bff472992401b9fecf89622a0151e6fcdab3707

  24. Empact commented at 11:46 PM on April 15, 2018: member

    utACK 2bff472

  25. jnewbery commented at 2:31 PM on April 16, 2018: member

    utACK 2bff472992401b9fecf89622a0151e6fcdab3707

  26. MarcoFalke merged this on Apr 16, 2018
  27. MarcoFalke closed this on Apr 16, 2018

  28. MarcoFalke referenced this in commit 07825088f9 on Apr 16, 2018
  29. ken2812221 deleted the branch on Apr 17, 2018
  30. PastaPastaPasta referenced this in commit 0a894fba66 on Jun 17, 2020
  31. PastaPastaPasta referenced this in commit 714beebe07 on Jun 27, 2020
  32. zkbot referenced this in commit 43ac2062f9 on Oct 28, 2020
  33. zkbot referenced this in commit 84a5830aaa on Nov 9, 2020
  34. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-20 09:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me