We also bump the other linters, although these don't change anything.
Change-Id: I07ddb8743804172a4e81a70b1ee4aa897e48dfca
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This avoids the need to duplicate our dependency list in multiple places
and allows us to take advantage of tox's dependency management
infrastructure, to ensure we always get the latest and greatest version
of a package allowed by upper-constraints. It also removes the slowest
pre-commit hook (by some distance), making pre-commit faster.
Change-Id: Ie241768231f180d5a672bf9f8fdc6a1eb8d7dfdb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
The change Ife39b55eb40c9cb8e61f1b2295b6d42cefe3a680 migrated mypy
configuration files from setup.cfg to pyproject.toml file, but a
comment in .pre-commit-config.yaml says to keep is in sync with
setup.cfg, which is incorrect.
This change updates comment in the .pre-commit-config.yaml file to
reflect the change.
Signed-off-by: Rajesh Tailor <ratailor@redhat.com>
Change-Id: I4d35b989e8c90b629bcb15438ad82f60f7ca8957
This change mainly just reorders the hooks
to be easier ot read and hopefully slightly
more efficent to run locally.
a number of extra useful hooks are added
such as the detect-private-key hook and
the check-shebang-scripts-are-executable
Thise were already available before but disabled.
finally the check-docstring-first is added
and the relevent module docs strings moved
if required.
Change-Id: I19a9e2adc9a029f4fbb819af1f128b874a5907e9
This change bumps to the latest version of each
of our pre-commit hooks. Of note this add py3.13
support to autopep8.
Codespell was also updated and the new spelling
issues resolved.
Change-Id: I1aab019ffb0ee9366a7d26515bef1335d09044df
Also remove the default Python version stanza since everything runs
Python 3 now.
Change-Id: If43485ce684a90b11f64790b1cb7b98f27290157
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This change mainly fixes incorrect use of backticks
but also adress some other minor issues like unbalanced
backticks, incorrect spacing or missing _ in links.
This change add a tox target to run sphinx-lint
as well as adding it to the relevent tox envs to enforce
it in ci. pre-commit is leveraged to install and execute
sphinx-lint but it does not reqiure you to install the
hooks locally into your working dir.
Change-Id: Ib97b35c9014bc31876003cef4362c47a8a3a4e0e
Add mypy so we can run these checks as part of our linting step. Note
that mypy is the last item in the list of checks since flake8 is going
to catch e.g. syntax issues which should be addressed first.
This also allows us to drop use of mypywrap: rather than wrapping mypy,
we can make use of mypy's configuration to specify the files we wish to
run checks on.
Change-Id: Ie51401ead4e31ccd70ab833c59cb397f802ff188
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
pre-commit is an effective linter runner. No need to duplicate things.
We are able to remove our homegrown "is this valid JSON" check by using
the one built into pre-commit. Beautiful!
Change-Id: I89398d4a1c5d4e7205f5f9c499cba0b4ff90fa46
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This chnage adds the pre-commit config and
tox targets to run codespell both indepenetly
and via the pep8 target.
This change correct all the final typos in the
codebase as detected by codespell.
Change-Id: Ic4fb5b3a5559bc3c43aca0a39edc0885da58eaa2
This bumps the version of flake8 and resolves some erroneous failures in
f-strings. A number of new E721 (do not compare types) class errors are
picked up, which are all addressed.
Change-Id: I7a1937b107ff3af8d1e5fe23fc32b120ef4697f7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Generated with 'pre-commit autoupdate' plus a manual update for the
local hacking plugin.
Change-Id: I4665d977bb8c720975d9259b4da0471c76e443a7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Sync the hacking version used with 'test-requirements.txt'. While we're
at it, bump the various plugins to their latest versions.
Change-Id: I851f67bd04950a30e88f9a737462f98559412cd9
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
autopep8 is a code formating tool that makes python code pep8
compliant without changing everything. Unlike black it will
not radically change all code and the primary change to the
existing codebase is adding a new line after class level doc strings.
This change adds a new tox autopep8 env to manually run it on your
code before you submit a patch, it also adds autopep8 to pre-commit
so if you use pre-commit it will do it for you automatically.
This change runs autopep8 in diff mode with --exit-code in the pep8
tox env so it will fail if autopep8 would modify your code if run
in in-place mode. This allows use to gate on autopep8 not modifying
patches that are submited. This will ensure authorship of patches is
maintianed.
The intent of this change is to save the large amount of time we spend
on ensuring style guidlines are followed automatically to make it
simpler for both new and old contibutors to work on nova and save
time and effort for all involved.
Change-Id: Idd618d634cc70ae8d58fab32f322e75bfabefb9d
This bumps the version of flake8 and pycodestyle to something much
newer, which resolves a long-standing warning about nested sets and
allows us to use new fangled features like f-strings if we so choose.
Change-Id: I0bb9077f1cea2243b7945e87cfa140f9cf89d558
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
We need this otherwise flake8 will run in Python 2 mode, which results
in syntax errors for Python 3-only syntax like kwarg-only functions.
Change-Id: Id55dbce1d9a19ccaa4fe605985fb165e9b3ab48c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
The flake8 hook for pre-commit installs its own flake8 which is
not what hacking is pinned to. This results in a bunch of errors.
By doing a local hook we can cause these to be the same.
There are flake8 exclusions in tox.ini that need to be used
in pre-commit. Also we should exclude svg files from the whitespace
modifications, because who cares.
Once those are fixed, running pre-commit -a fixes some whitespace
issues. While the normal use isn't to run -a - if someone does make
a patch that touches any of these they'll get erroneous unrelated
errors compared to their lower work - so fix all of the existing
issues, which are mostly space-at-end-of-line issues it seems.
Change-Id: I78e753492e99c03b30a0a691db3bd75ee3d289c9
This nifty tool provides a extensible way to configure pre-commit hooks
to do everything from running linters to spellchecking [1] and has
already been adopted by a few OpenStack projects [2]. Let's start using
it as a faster, more automatic alternative to the 'fast8' tox target and
iterate on it as we find more things to use it for. The 'fast8' target
is not deprecated though a note is included for end-users to alert them
to this great new tool.
Note that the 'check-executables-have-shebangs' actually failed and
highlighted that the 'contributor/development-environment.rst' document
was marked as executable when it shouldn't have been. This is corrected.
[1] https://pre-commit.com/
[2] https://review.opendev.org/#/q/file:.pre-commit-config.yaml
Change-Id: I256e75eceeb3495dce04885ca42d16adb4160cf3
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>