neutron-lib/doc/source/usage.rst
Boden R c61976b66d Use new checks in hacking 0.12
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
2016-12-15 07:03:58 -07:00

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:

  1. Update your project's tox.ini to use neutron_lib.hacking.checks.factory for its local-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
  2. Update your project's tox.ini enable any flake8 extensions neutron-lib's tox.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 the enable-extensions in their tox.ini.

  3. 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 the incubating_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 into factory. Announcements regarding neutron-lib adopter hacking checks will be communicated via openstack-dev email list and neutron meetings.