The version in use is way old and does not support Python 3.11. Bump it.
Change-Id: I047293ed51e249c69dc64c32029680439e3972fd
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Running it turned up a bunch of false positives around delayed LOG
string interpolation, so we need to fix our pattern match from
`.format` to `.format(` to avoid incorrectly catching things like
`.format_message()`.
We also add the E checks in the Nova integration tests. As we saw in
the previous commit, sometimes flake8 gets bugs that caused things
that would normally get flagged to not actually get flagged, like
lines longer than 80 chars in docstrings. By running Nova
integration with E, we make sure any such changes are caught ahead of
time.
Depends-on: https://review.opendev.org/c/openstack/nova/+/874517
Change-Id: I236a25e5380b5492009d587e76347e52ec50c09f
This currently fails with:
H212: Use assert{type(A),B} instance
which makes no sense. What we actually want is for users to use use
assertIsInstance. Correct this.
Change-Id: I99b01bf2349aede0e90b5fb3702c5637aad412bc
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Previously, we detected non-delayed string interpolation by checking
for the presence of '.format'. This can turn up false positives, like
'.format_message('. Fix this by checking for '.format('.
Hacking version 6.0.0 got released with a bumped and fixed version of
flake8 that started detecting pep8 errors lurking in code, but also
started detecting these false positives, so once this patch is merged
we'll need a new hacking release so that projects can correctly bump
their hacking version.
Change-Id: I49e12b0dedbfd7820984cc5393f9ca2f72be89cb
There is a bug [1] in older flake8 that we need to pick up. In
particular, Nova has at least one line longer than 80 characters in it
[2] because of that bug. Our own unit tests start breaking with the
new flake8, so we need to fix whitespace for one `if`, and start
calling flake8 with `--enable-extentions` to force flake8 to load
extensions decorated with @off_by_default.
[1] https://github.com/PyCQA/flake8/issues/1534
[2] 5c32d5efe1/nova/image/glance.py (L392)
Change-Id: I7799049924b5a2cde867c88c03154c36831c9670
This patch removes skipdist=True as otherwise the hacking source is not
installed in the venv and the unit test discovery fails to load most of
the test cases.
Change-Id: Ie2a39d9d1009b4be1f0ed9e6b50b4475969b03e5
We are not testing with py36 and py37 so we cannot be sure hacking works
with these versions.
Add releasenote that also mentions the previous changes in py35 and
flake8 support.
Sem-Ver: api-break
Change-Id: I798dd39afcf2f16a8660ab597b6f5bae70ab2a81
flake 4 dropped support for py35 so this patch drops py35 support from
hacking too
Change-Id: Ia17d6978f4d7db776d986b75c3879cb9dc672e08
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Python3.10 has become more strict when parsing code that contains syntax
errors, fix those.
Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: Ic9f2cb0df6e52b23b17dd9494b6fceeef9626d8a
UPPER_CONSTRAINTS_FILE is old name and deprecated
This allows to use upper-constraints file as more
readable way instead of UPPER_CONSTRAINTS_FILE=<lower-constraints file>.
Change-Id: I66af58e30d01ed329dd19f243eb4862985b886af
Regardless of H103 being selected by the user, if the license is not
an exact apache2 license, it will be printed out poluting the output.
With this change the comparison will be printed along with the error
message, so will not be visible if H103 was not selected.
Change-Id: Id526d83626e377aedd0bd2a998fc7d6e01058d3e
Setuptools v54.1.0 introduces a warning that the use of dash-separated
options in 'setup.cfg' will not be supported in a future version [1].
Get ahead of the issue by replacing the dashes with underscores. Without
this, we see 'UserWarning' messages like the following on new enough
versions of setuptools:
UserWarning: Usage of dash-separated 'description-file' will not be
supported in future versions. Please use the underscore name
'description_file' instead
[1] https://github.com/pypa/setuptools/commit/a2e9ae4cb
Change-Id: I67c7fb8eebc0334d3dba4c821d1fa5af4b672145
Setuptools v54.1.0 introduces a warning that the use of dash-separated
options in 'setup.cfg' will not be supported in a future version [1].
Get ahead of the issue by replacing the dashes with underscores. Without
this, we see 'UserWarning' messages like the following on new enough
versions of setuptools:
UserWarning: Usage of dash-separated 'description-file' will not be
supported in future versions. Please use the underscore name
'description_file' instead
[1] https://github.com/pypa/setuptools/commit/a2e9ae4cb
Change-Id: I6083f49c2ba2baf80e20968a1f2d809089196613
This allows hacking to be used the same way flake8 is used as
a pre-commit hook. This allows repository owners to control bumping
using `pre-commit auto-update` when they feel appropriate.
Change-Id: Id00b79ff3006c390f925dcc5031ac503374cf9bd
Needed-By: https://review.opendev.org/c/openstack/tripleo-heat-templates/+/783828
- bump template to wallaby to make use of py39 job
- advertise py39 support in metadata
- clean default tox envlist to be python version agnostic
Change-Id: I47ce403f35460bcf27d044450c7e6ed00cda7c4f
Hacking PyPI presence does miss to expose few essential links related
to the project, so we add them to avoid forcing users to dig into
the documentation to find them.
Change-Id: I534ca4509bdb5f6846a41bf7cd25dd1773abaca7
Many projects use mocking in their unit tests, and most do not realize
that there is a difference between "import mock" and "import
unittest.mock", assuming that both use a standard part of the Python
library.
We've seen many cases where mock is not listed in the project's
requirements, but the code imports the third party mock instead of
unittest.mock. We've also seen a few break due to this, once their
dependencies have stopped pulling in that package for them.
There have also been several projects that have taken the effort to
switch all of there "import mock" statements over to "import
unittest.mock", as well as removing mock from their requirements, only
to then accidentally merge a patch that does "import mock" again because
it is hard to notice in code reviews.
This check is on by default. If a project is using the mock lib, then
they are able to explicitly do so by disabling this check. Otherwise,
projects don't need to take any action to get this protection, since
this is now the recommended default.
Change-Id: I8d255a00792a19279074703a8209a3699b480fd0
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This adds checking for using .format() instead of % when looking for
cases of preformatting log strings.
Change-Id: Ia12f898ca3d206c9da0e5057c7223e124ee2548c
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
We have added a check to make sure format strings and any args are being
passed in to be formatted as needed by the logger. The check did not
take into account string formatting that may be needed in preparing the
value args. There are some cases where this is needed, and we should not
be raising an error if the string formatting is being done there.
This adds a new test string and updates the hacking check to account for
these cases so the new hacking release does not raise unnecessary
errors.
Change-Id: Ie4e3f95d24dc954deb7336835a6f9b7bf54c9674
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This patch will copy the most common hacking rules used in diff.
projects and add them to hacking itself.
Currently, added assert_true_instance, assert_equal_type
assert_raises_regexp, assert_true_or_false_with_in
assert_equal_in
Change-Id: I122d250cab90964c346e9d53046a97c25054bc00
Hacking check was failing to match on lines that should have been
flagged an issue. This fixes the check and adds unit tests to validate
the check is working as expected.
Change-Id: I20e3b54a0c5830565e5d4bbb3bbc8b4921c82fb2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
The regex for this check was wrong, resulting in misses. This fixes the
checks for string interpolation and adds unit tests to make sure we are
actually handling the cases we expect to be.
Change-Id: Id61094bb8ee8e93275c51c53caeb9ca27252b144
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we don't need it
in lower-constraints and requirements.
These changes will help us to drop `mock` from openstack/requirements
Change-Id: I71a09f2eddd3a344225cb69f9679e99fdeb3e2db
It is difficult to keep the py35 upper constraints on reqiorements
repo's upper-constarint.txt file as update-constraint tools generate
the new file everytime with official supported python version only
which is py3.6 and py3.8 for Victoria cycle
- https://review.opendev.org/#/c/730428
Let's keep the py3.5 constraints in-tree which can be used in py35
unit test job.
Change-Id: I397edb7eccdb23656d1a618635d9cb9c0c901d39
Switch to openstackdocstheme 2.2.1 and reno 3.1.0 versions. Using
these versions will allow especially:
* Linking from HTML to PDF document
* Allow parallel building of documents
* Fix some rendering problems
Update Sphinx version as well.
openstackdocstheme renames some variables, so follow the renames
before the next release removes them. A couple of variables are also
not needed anymore, remove them.
Set openstackdocs_pdf_link to link to PDF file. Note that
the link to the published document only works on docs.openstack.org
where the PDF file is placed in the top-level html directory. The
site-preview places the PDF in a pdf directory.
Set openstackdocs_auto_name to use 'project' as name.
Change pygments_style to 'native' since old theme version always used
'native' and the theme now respects the setting and using 'sphinx' can
lead to some strange rendering.
See also
http://lists.openstack.org/pipermail/openstack-discuss/2020-May/014971.html
Change pygments_style to 'native' since old theme version always used
'native' and the theme now respects the setting and using 'sphinx' can
lead to some strange rendering.
See also
http://lists.openstack.org/pipermail/openstack-discuss/2020-May/014971.html
Change-Id: I8e6c4b1d09e5f56b505c6006ea048baf896444c3