Fix E275 errors in lint-python.py with flake8 5.0.4
After updating my venv to Python 3.6.15 and reinstalling flake8 (at the current version, 5.0.4), it now throws quite a few E275 which are fixed with this scripted diff.
Fix E275 errors in lint-python.py with flake8 5.0.4
After updating my venv to Python 3.6.15 and reinstalling flake8 (at the current version, 5.0.4), it now throws quite a few E275 which are fixed with this scripted diff.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
First, sorry I missed duplicating #26257 (but I also think a scripted diff is the best way to make this change). @MarcoFalke which other whitespace did you have in mind?
IMO if we are using a specific linter then we should try to ensure those lints pass (or are disabled) and not more without adding additional lints for it. Otherwise if we change “all” whitespace today, we are likely to miss more of the same un-linted whitespace errors being introduced in the future.
scripted diff is the best way
The scripted diff as of now may modify out-of-git-tree files with the wildcard. You’d have to use git
to get the file list. Also, it doesn’t pass CI as of now.
@MarcoFalke which other whitespace did you have in mind?
Anything you could come up with. Pretty sure there are other whitespace/formatting checks in flake. If not, you can take one from black
as example. (Not saying you should do this, just presenting this as a reason against).
specific linter then we should try to ensure those lints pass
Yes, the only supported version is the one installed by CI. Obviously we can’t support future versions that may not have been released yet or even written.
errors being introduced in the future
Yes, so fixing this without enforcement seems doubly-bad. (Again, not saying you should do this, just presenting this as another reason against).
80@@ -81,7 +81,7 @@ def witness_script_test(self):
81 # Create a new P2SH-P2WSH 1-of-1 multisig address:
82 eckey = ECKey()
83 eckey.generate()
84- embedded_privkey = bytes_to_wif(eckey.get_bytes())
85+ embedded_privkey = bytes_to_wif (eckey.get_bytes())
Taking a look at the number of conflict, see also my template answer:
Thank you for your contribution. While this stylistic change makes sense on its own, it comes at a cost and risk for the project as a whole. The weak motivation for the change does not justify the burden that it places on the project. A burden could be any of the following:
For more information about refactoring changes and stylistic cleanup, see
Generally, if the style is not mentioned nor enforced by the developer notes, we leave it up to the original author to pick whatever fits them best personally and then leave it that way until the line is touched for other reasons.
Let me know if you have any questions.
OK thanks.
Well, I’ll switch this to use git files and makes sure it passes CI and leave it as an option vs #26257.
71@@ -72,7 +72,7 @@ def create_transaction(self, *, txid, input_details=None, addr, amount, privkey)
72 def run_test(self):
73 eckey = ECKey()
74 eckey.generate()
75- self.privkey = bytes_to_wif(eckey.get_bytes())
76+ self.privkey = bytes_to_wif (eckey.get_bytes())
if(
regex
-BEGIN VERIFY SCRIPT-
git grep -l "\ assert(" -- '*.py' | grep -v "src/" | xargs sed -i 's/\ assert(/\ assert\ (/g'
git grep -l "\ not(" -- '*.py' | grep -v "src/" | xargs sed -i 's/\ not(/\ not\ (/g'
git grep -l "\ if(" -- '*.py' | grep -v "src/" | xargs sed -i 's/\ if(/\ if\ (/g'
-END VERIFY SCRIPT-
Thank you for your contribution. While this stylistic change makes sense on its own, it comes at a cost and risk for the project as a whole. The weak motivation for the change does not justify the burden that it places on the project.
OK. I will just apply the patch locally as I’m using newer flake8.
flake8 to 5.0.4
mypy to 0.971
pyzmq to 24.0.1
vulture to 2.6
When python was bumped to 3.6.15 I made a new venv, installed flake8 et. al. (with a simple pip install flake8
– not using the pinned versions from ci/lint/04_install.sh) and ran the linter, which resulted in the E275 errors that this change fixed, but no E301, E302, E303, … errors. So I suppose newer flake8 is checking E275 by default?
I’m not sure if we expect people to manually extract and locally install pinned versions from that ci script (it is linked from the readme), add a requirements.txt to test/
, or leave the status quo. But I suspected I would not be the only person to encounter this (and had I used GitHub’s search function like a good netizen I would have seen I was correct without needing to open this conflicting PR!)