Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

githooks: Replace pre-commit tool with simple shell script #1581

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

swick
Copy link
Contributor

@swick swick commented Jan 17, 2025

This gets is mypy in addition to ruff check and ruff format. I spent way too many hours trying to make things work with pre-commit and I don't think it's even possible. CI runs the check script directly, the git-hooks integration only when a commit changes something in tests.

githooks: Replace pre-commit tool with simple shell script

It's basically impossible to run mypy with pre-commit because it will
ignore the repo config and check all files changed the commit. The
dbusmock templates are special and mypy fails on them so we use the mypy
config to skip them.

This introduces a new script which checks the python tests and installs
all the required tools into a python virtual environment. It also
changes to pre-commit hook to call the script if any of the files in
tests changed and uses git stash push/pop to get the test a clean state
of the repo.

swick added 3 commits January 17, 2025 16:29
instead of the entire string which can contain other data, such as the
bus name.

Also adds an assert to ensure template is actually of type string which
makes mypy happy.
It's basically impossible to run mypy with pre-commit because it will
ignore the repo config and check all files changed the commit. The
dbusmock templates are special and mypy fails on them so we use the mypy
config to skip them.

This introduces a new script which checks the python tests and installs
all the required tools into a python virtual environment. It also
changes to pre-commit hook to call the script if any of the files in
tests changed and uses git stash push/pop to get the test a clean state
of the repo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

1 participant