lint: convert lint-python-mutable-default-parameters.sh to Python #24800

pull KevinMusgrave wants to merge 1 commits into bitcoin:master from KevinMusgrave:port-lint-script-to-python changing 2 files +72 −52
  1. KevinMusgrave commented at 4:18 pm on April 7, 2022: contributor

    This converts one of the linter scripts to Python. Reference issue: #24783

    The approach is to just call git grep using subprocess.run.

    Alternative approaches could be to use Python instead of git grep (I’m not sure how) or use pylint --disable=all --enable=W0102, though that requires installation of pylint.

  2. DrahtBot added the label Tests on Apr 7, 2022
  3. in test/lint/lint-python-mutable-default-parameters.py:18 in 0335a619c6 outdated
    13+
    14+
    15+def main():
    16+    command = "git grep -E".split(" ")
    17+    command.append(r"^\s*def [a-zA-Z0-9_]+\(.*=\s*(\[|\{)")
    18+    command.extend("-- *.py".split(" "))
    


    laanwj commented at 1:15 pm on April 8, 2022:
    lets just write this as command.extend(["--", "*.py"])

    KevinMusgrave commented at 2:24 pm on April 8, 2022:
    Done, I put the whole command into an array
  4. in test/lint/lint-python-mutable-default-parameters.py:16 in 0335a619c6 outdated
    11+import subprocess
    12+import sys
    13+
    14+
    15+def main():
    16+    command = "git grep -E".split(" ")
    


    laanwj commented at 1:16 pm on April 8, 2022:
    command = ["git", "grep", "-E"], no need to call split here

    KevinMusgrave commented at 2:24 pm on April 8, 2022:
    Done, I put the whole command into an array
  5. in test/lint/lint-python-mutable-default-parameters.py:20 in 0335a619c6 outdated
    15+def main():
    16+    command = "git grep -E".split(" ")
    17+    command.append(r"^\s*def [a-zA-Z0-9_]+\(.*=\s*(\[|\{)")
    18+    command.extend("-- *.py".split(" "))
    19+    output = subprocess.run(command, stdout=subprocess.PIPE, universal_newlines=True)
    20+    output = output.stdout
    


    laanwj commented at 1:17 pm on April 8, 2022:
    Would prefer to use output.stdout in following code instead of this assignment.

    KevinMusgrave commented at 2:24 pm on April 8, 2022:
    Done
  6. MarcoFalke commented at 2:44 pm on April 8, 2022: member
  7. Converted lint-python-mutable-default-parameters.sh to python
    Change permission
    
    Change argument so that it's compatiable with python 3.6
    
    Change comment to docstring
    
    Remove .split, .append, .extend calls. Remove 'output' variable assignment
    e8e48fa82b
  8. KevinMusgrave force-pushed on Apr 8, 2022
  9. KevinMusgrave commented at 3:56 pm on April 8, 2022: contributor
  10. MarcoFalke commented at 9:47 am on April 11, 2022: member
    review ACK e8e48fa82bdce3f0c1da0693148867befa221de7
  11. MarcoFalke merged this on Apr 11, 2022
  12. MarcoFalke closed this on Apr 11, 2022

  13. sidhujag referenced this in commit 50195ebdc9 on Apr 11, 2022
  14. DrahtBot locked this on Apr 11, 2023

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: 2024-11-17 06:12 UTC

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