-
Notifications
You must be signed in to change notification settings - Fork 35.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lint: convert lint-python-mutable-default-parameters.sh to Python #24800
lint: convert lint-python-mutable-default-parameters.sh to Python #24800
Conversation
def main(): | ||
command = "git grep -E".split(" ") | ||
command.append(r"^\s*def [a-zA-Z0-9_]+\(.*=\s*(\[|\{)") | ||
command.extend("-- *.py".split(" ")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just write this as command.extend(["--", "*.py"])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I put the whole command into an array
|
||
|
||
def main(): | ||
command = "git grep -E".split(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
command = ["git", "grep", "-E"]
, no need to call split here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I put the whole command into an array
command.append(r"^\s*def [a-zA-Z0-9_]+\(.*=\s*(\[|\{)") | ||
command.extend("-- *.py".split(" ")) | ||
output = subprocess.run(command, stdout=subprocess.PIPE, universal_newlines=True) | ||
output = output.stdout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to use output.stdout
in following code instead of this assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits |
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
60fe55c
to
e8e48fa
Compare
@MarcoFalke Done |
review ACK e8e48fa |
…ters.sh to Python e8e48fa Converted lint-python-mutable-default-parameters.sh to python (TakeshiMusgrave) Pull request description: This converts one of the linter scripts to Python. Reference issue: bitcoin#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. ACKs for top commit: MarcoFalke: review ACK e8e48fa Tree-SHA512: 7f6f4887dee02c9751b225a6a131fb705868859c4a9af25bb3485cda2358650486b110f17adf89d96a20f212d7d94899922a07aab12c8dc11984cfd5feb7a076
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.