ardupilot
ardupilot copied to clipboard
Add `# flake8: noqa` directive to all failing files
% pre-commit run --all-files flake8
flake8...................................................................Passed
A continuation of:
- #30288
Similar to the request at https://github.com/ArduPilot/ardupilot/pull/30290#pullrequestreview-2923697863
The 15 different commits are intentional, following the logic at https://github.com/ArduPilot/ardupilot/pull/30270#issuecomment-2969707706
@peterbarker @Ryanf55 Your reviews, please.
% pre-commit run --all-files should pass on this branch!
@peterbarker @Ryanf55 Your reviews, please.
%
pre-commit run --all-filesshould pass on this branch!
Sorry, it does not pass. Any tips? I've never seen this until the recent changes.
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit run --all-files
An error has occurred: InvalidManifestError:
==> File /home/ryan/.cache/pre-commit/repodu8n_5hd/.pre-commit-hooks.yaml
==> At Hook(id='check-added-large-files')
==> At key: stages
==> At index 0
=====> Expected one of commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push but got: 'pre-commit'
Check the log at /home/ryan/.cache/pre-commit/pre-commit.log
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ git log -n 1
commit 91ea7270a913cac9c3f5b693a9fea95e353c28b5 (HEAD -> add-flake8-noqa-directive)
Author: Christian Clauss <[email protected]>
Date: Fri Jun 13 12:47:50 2025 +0200
wscript: Add # flake8: noqa linter directive
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ python3 -m pip list | grep pre-commit
pre-commit 2.17.0
https://pypi.org/project/pre-commit --> v4.2.0
% pre-commit --version
pre-commit 4.2.0
Do you have pipx or uv to run the current version of pre-commit on-the-fly?
% pipx run pre-commit run --all-files
or
% uv tool run pre-commit run --all-files
or
% uvx pre-commit run --all-files
pre-commit run --all-files flake8
I tried upgrading pre-commit, it still doesn't work.
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit run --all-files flake8
[INFO] Initializing environment for https://github.com/pycqa/flake8.
[INFO] Installing environment for https://github.com/pycqa/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy immediately after install, please open an issue describing your environment
more info:
virtualenv python version did not match created version:
- actual version: <<error retrieving version from /home/ryan/.cache/pre-commit/repokt8vbszh/py_env-python3.10/bin/python>>
- expected version: 3.10.12.final.0
Check the log at /home/ryan/.cache/pre-commit/pre-commit.log
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ python3 -m pip show pre-commit
Name: pre_commit
Version: 4.2.0
Summary: A framework for managing and maintaining multi-language pre-commit hooks.
Home-page: https://github.com/pre-commit/pre-commit
Author: Anthony Sottile
Author-email: [email protected]
License: MIT
Location: /home/ryan/.local/lib/python3.10/site-packages
Requires: cfgv, identify, nodeenv, pyyaml, virtualenv
Required-by:
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ cat /home/ryan/.cache/pre-commit/pre-commit.log
### version information
pre-commit version: 4.2.0 git --version: git version 2.34.1 sys.version: 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] sys.executable: /usr/bin/python3 os.name: posix sys.platform: linux
### error information
An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy immediately after install, please open an issue describing your environment
more info:
virtualenv python version did not match created version:
- actual version: <<error retrieving version from /home/ryan/.cache/pre-commit/repokt8vbszh/py_env-python3.10/bin/python>>
- expected version: 3.10.12.final.0
Traceback (most recent call last): File "/home/ryan/.local/lib/python3.10/site-packages/pre_commit/error_handler.py", line 73, in error_handler yield File "/home/ryan/.local/lib/python3.10/site-packages/pre_commit/main.py", line 417, in main return run(args.config, store, args) File "/home/ryan/.local/lib/python3.10/site-packages/pre_commit/commands/run.py", line 442, in run install_hook_envs(to_install, store) File "/home/ryan/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 229, in install_hook_envs _hook_install(hook) File "/home/ryan/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 90, in _hook_install raise AssertionError( AssertionError: BUG: expected environment for python to be healthy immediately after install, please open an issue describing your environment
more info:
virtualenv python version did not match created version:
- actual version: <<error retrieving version from /home/ryan/.cache/pre-commit/repokt8vbszh/py_env-python3.10/bin/python>>
- expected version: 3.10.12.final.0
I also tried clean, uninstall and reinstall.
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit clean
Cleaned /home/ryan/.cache/pre-commit.
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit uninstall
pre-commit uninstalled
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
ryan@B650-970:~/Dev/ardu_ws/src/ardupilot$ pre-commit run --all-files flake8
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/pycqa/flake8.
[INFO] Installing environment for https://github.com/pycqa/flake8.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: AssertionError: BUG: expected environment for python to be healthy immediately after install, please open an issue describing your environment
more info:
virtualenv python version did not match created version:
- actual version: <<error retrieving version from /home/ryan/.cache/pre-commit/repougjqlenx/py_env-python3.10/bin/python>>
- expected version: 3.10.12.final.0
Check the log at /home/ryan/.cache/pre-commit/pre-commit.log
With pipx, it passes.
% python --version
% python -m pre-commit --version
% python -m pre-commit run --all-files
python -m pre-commit run --all-files
$ python --version
Python 3.10.12
$ python -m pre-commit --version
/usr/bin/python: No module named pre-commit
which pre-commit
/home/ryan/.local/bin/pre-commit
My pre-commit environment is hosed, feel free to merge based on other approvals.
My pre-commit environment is hosed, feel free to merge based on other approvals.
This does not fill me with confidence. tridge also ended up with a "hosed" pre-commit environment. What's going wrong, can we document our way out of it?
I have reverted the changes to the pre-commit file, so the test criteria for this pull request are:
- Run flake8
- Run
Tools/scripts/run_flake8.py - The GitHub Actions must pass.
% flake8 .
or
% python -m flake8 .
or
% pipx run flake8 .
or
% uv tool run flake8 .
or
% uvx flake8 .
Merged, thanks!
My pre-commit environment is hosed, feel free to merge based on other approvals.
This does not fill me with confidence. tridge also ended up with a "hosed" pre-commit environment. What's going wrong, can we document our way out of it?
@cclauss and I were testing other nonstandard workflows and hacking away in pre-commit's hidden directories. pre-commit has been solid for me. All of the issues that Tridge has raised to me with pre-commit have workarounds that we can work to smooth out.