Use pre-commit for style checks
Locally you have to pip install pre-commit
and then pre-commit install
to install the hook.
I have set it such that black updates the offending changes automatically. Note that the auto-format doesn't touch unstaged changes in the same file.
Flake8 doesn't support automatic fixing (even when easy), so that's another reason to look into Ruff.