ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Tools: Bring flake8 speed improvements to pre-commit

Open TunaLobster opened this issue 3 years ago • 3 comments

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(-)

TunaLobster avatar Aug 24 '22 20:08 TunaLobster

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

TunaLobster avatar Aug 25 '22 20:08 TunaLobster

@peterbarker Removed the class variables. Let me know what you think about this one and then maybe an astyle check can be added.

TunaLobster avatar Sep 06 '22 17:09 TunaLobster

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')

TunaLobster avatar Sep 15 '22 19:09 TunaLobster

@peterbarker Bump for review?

TunaLobster avatar Jan 31 '23 15:01 TunaLobster

Merged, thanks!

peterbarker avatar Mar 11 '23 03:03 peterbarker