Commit Graph

12 Commits

Author SHA1 Message Date
Omar Sandoval
9d7f70aeaa pre-commit: include vmtest/rootfsbuild.py in vermin
The only error is about typing.Literal, which we already have guarded in
a sys.version_info check, so we can add novermin.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-09-07 09:04:43 -07:00
Stephen Brennan
e349b9e467 Add more pre-commit hooks
The "pre-commit-hooks" repo contains a few hooks that enforce some nice,
common sense guidelines. The "vermin" hook checks compatibility with a
supplied minimum Python version requirement, both checking the syntax
and standard library usage. It's very helpful for identifying
incompatible code before getting to the CI steps.

Rather than repeatedly excluding the contrib directory, set it to be
excluded at the top-level.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-09-06 15:53:49 -07:00
Omar Sandoval
50258ad0b4 pre-commit: update Black to 23.7.0
This added one minor style fix.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2023-07-19 14:51:36 -07:00
Stephen Brennan
e5f10c68a8 pre-commit: Update isort version to 5.12.0
Currently on Ubuntu 22.04 LTS, pre-commit hook installation is broken
for isort, with an error that can be seen at [1]. The solution is to
update isort to 5.12.0.

[1]: https://github.com/PyCQA/isort/issues/2077

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2023-01-30 10:24:41 -08:00
Omar Sandoval
08adab777e pre-commit: update isort, Black, and flake8
No changes required. mypy is still pinned for the sake of Python 3.6.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-12-13 15:38:15 -08:00
Omar Sandoval
be96cf6e7f pre-commit: add --show-error-codes to mypy
This is useful for adding type: ignore[<code>] comments.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-12-13 15:01:15 -08:00
Omar Sandoval
a0a54edc1f Create contrib directory
It's come up several times that it'd be nice to have somewhere to dump
drgn scripts that people write while debugging without requiring them to
be cleaned up and scrutinized in code review. Serapheim Dimitropoulos
noted that several projects have a "contrib" directory for this purpose.
See [1]. Let's create one, document it, exclude it from pre-commit, and
move our (mostly unmaintained) examples there.

1: https://drewdevault.com/2020/06/06/Add-a-contrib-directory.html

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-11-16 13:17:50 -08:00
Omar Sandoval
1c0dbcd917 pre-commit: add flake8
This has been useful to run manually before, but I haven't added it to
the CI because it was somewhat noisy. But, it reports some really useful
warnings, so let's configure it for our needs and add it to pre-commit.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-05-17 15:26:41 -07:00
Omar Sandoval
d9b8392d7f pre-commit: roll mypy back to v0.931
pre-commit/mirrors-mypy@d37f9c4f0c added
"from __future__ import annotations", which doesn't work on Python 3.6.
Python 3.6 is EOL, so it's probably time to drop it, but that should be
a different, intentional change.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-03-31 17:00:26 -07:00
Omar Sandoval
fbfe7f45ad pre-commit: update Black and mypy
Black 22.3.0 fixes psf/black#2964, which was breaking the CI with:

  ImportError: cannot import name '_unicodefun' from 'click'

mypy v0.942 doesn't complain about anything new.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-03-31 16:28:40 -07:00
Omar Sandoval
7f232a4815 pre-commit: update Black
Black 22.1.0 has some style changes: string prefixes are normalized and
spaces around the power operator are removed.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2022-02-12 13:48:49 -08:00
Stephen Brennan
ae377984d4 Add pre-commit
During PRs, lint and mypy errors can show up in the CI tests, which is
useful, but can introduce unnecessary churn on the PR as small lint
fixes are pushed. This commit adds (optional) support for pre-commit, a
tool which can be configured to run as a git pre-commit hook, running
linters on all changed code to catch issues before you push your code.

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
2022-01-14 13:31:16 -08:00