ardupilot
ardupilot copied to clipboard
Tools: Bring flake8 speed improvements to pre-commit
Bringing the same improvements added in #21035 to the pre-commit script.
Also I was thinking about the command line length limit. Hopefully by the time we get to close to that limit, the tag won't be necessary and the whole project will pass with flake8 . and the current .flake8 config file.
This commit did pass it's own check! (also shows it does work as a hook)
~/ardupilot$ git commit -m "Tools: Bring flake8 speed improvements to pre-commit"
***** Checking (Tools/gittools/pre-commit.py)
[pr/udpate-pre-commit dd08d5754c] Tools: Bring flake8 speed improvements to pre-commit
1 file changed, 21 insertions(+), 16 deletions(-)
Created an example to show adding astyle to pre-commit.py and reusing the same patterns used here. https://github.com/TunaLobster/ardupilot/compare/pr/udpate-pre-commit...TunaLobster:ardupilot:pre/add-astyle-pre-commit
@peterbarker Removed the class variables. Let me know what you think about this one and then maybe an astyle check can be added.
Working on python 2.7 and 3.8. Looks like check_output is still present in 3.11.0rc2 with no notes of being deprecated.
cpjohns@machine:~/ardupilot$ python2 Tools/gittools/pre-commit.py
***** WARNING: (Tools/gittools/pre-commit.py) has unstaged changes
***** Checking (Tools/gittools/pre-commit.py)
***** Flake8 check failed: (Tools/gittools/pre-commit.py:34:40: W291 trailing whitespace
)
cpjohns@machine:~/ardupilot$ python2 Tools/gittools/pre-commit.py
***** WARNING: (Tools/gittools/pre-commit.py) has unstaged changes
***** Checking (Tools/gittools/pre-commit.py)
cpjohns@machine:~/ardupilot$ python Tools/gittools/pre-commit.py
***** WARNING: (Tools/gittools/pre-commit.py) has unstaged changes
***** Checking (Tools/gittools/pre-commit.py)
cpjohns@machine:~/ardupilot$ python Tools/gittools/pre-commit.py
***** WARNING: (Tools/gittools/pre-commit.py) has unstaged changes
***** Checking (Tools/gittools/pre-commit.py)
***** Flake8 check failed: (b'Tools/gittools/pre-commit.py:34:40: W291 trailing whitespace\n')
@peterbarker Bump for review?
Merged, thanks!