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>
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>
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>
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>
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>
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>
Black 22.3.0 fixespsf/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>
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>
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>