Neutron recently updated their usage of hacking to use version 0.12 [1] that now contains the hacking check check_delayed_string_interpolation who's off_by_default value is initially True (i.e. disabled). This hacking check is defined in neutron_lib, but hasn't been registered in our factory and isn't being consumed directly [2]. This patch takes a simple approach to reusing openstack-dev hacking checks: - Removes all traces of neutron-lib's version of the check; no one is using it [2]. - Bumps our version of hacking to use 0.12 so we can use the checks in that release. - Enables the check via enabled extensions in tox.ini as neutron did [1]. - Updates our hacking check usage, noting that adopters should enable the same extensions we do (via tox.ini). [1] https://review.openstack.org/#/c/394817/ [2] http://codesearch.openstack.org/?q=check_delayed_string_interpolation&i=nope&files=&repos= Change-Id: Ie9448317855b9cba6092cd0f63b77d26a562a5c9
2.4 KiB
Usage
To use neutron-lib in a project:
import neutron_lib
Hacking Checks
The neutron_lib.hacking
package implements a number of
public hacking
checks intended to help adopters validate their compliance with the
latest hacking standards.
To adopt neutron-lib's hacking checks:
Update your project's
tox.ini
to useneutron_lib.hacking.checks.factory
for itslocal-check-factory
.For example in your
tox.ini
:[hacking] local-check-factory = neutron_lib.hacking.checks.factory
If your project needs to register additional project specific hacking checks, you can define your own factory function that calls neutron-lib's
factory
function.For example in your project's python source:
def my_factory(register): # register neutron-lib checks neutron_lib_checks.factory(register) # register project specific checks register(my_project_check)
And use your project's own factory in
tox.ini
:[hacking] local-check-factory = myproject.mypkg.my_factory
Update your project's
tox.ini
enable any flake8 extensions neutron-lib'stox.ini
does. These are hacking checks otherwise disabled by default that neutron-lib expects to run.For example in neutron-lib's
tox.ini
:[flake8] # H904: Delay string interpolations at logging calls enable-extensions=H904
In the example above, adopters should also add
H904
to theenable-extensions
in theirtox.ini
.Actively adopt neutron-lib hacking checks that are incubating and will soon become adopter checks by manually running the checks on your project. This can be done by modifying your
tox.ini
to use theincubating_factory
in neutron-lib:[hacking] local-check-factory = neutron_lib.hacking.checks.incubating_factory
And then manually running pep8 on your project:
tox -e pep8
New adopter hacking checks in neutron-lib will be registered via the
incubating_factory
while sub-projects are adopting the new check(s) and then be moved out of incubating and intofactory
. Announcements regarding neutron-lib adopter hacking checks will be communicated via openstack-dev email list and neutron meetings.