Commit Graph

1074 Commits

Author SHA1 Message Date
Takashi Kajinami 977ee03534 Drop tox target for python 3.5
... because the minimum version currently supported is 3.8.

Change-Id: Iebae234e47a3d04c0587d447f5672c683fbb04e0
2024-01-31 13:04:12 +09:00
Zuul 86e3688c66 Merge "Bump flake8-docstrings version" 2023-12-06 17:49:22 +00:00
Stephen Finucane ba52c7bebe Bump flake8 version
Change-Id: Ie5fd08a6c624e3ddc8f9fb237143c98eeec34ab9
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-12-05 12:22:59 +00:00
Stephen Finucane 99fc019372 Bump flake8-docstrings version
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>
2023-10-02 11:23:57 +01:00
Zuul 77977ceb56 Merge "Fix nova integration job" 2023-09-25 06:20:54 +00:00
Zuul 9bf3149831 Merge "Use py3 as the default runtime for tox" 2023-09-05 15:05:07 +00:00
Artom Lifshitz 7868295f9b Fix nova integration job
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
2023-08-13 08:40:13 +02:00
niuke 88faeaf279 Use py3 as the default runtime for tox
Moving on py3 as the default runtime for tox to avoid to update
this at each new cycle.

Change-Id: Ibbe6fde1fe22d087f607616571e0a273b0712c40
2023-07-31 11:31:06 +08:00
Stephen Finucane f4c3128ac9 Improve H212 failure message
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>
2023-05-03 11:52:31 +01:00
Artom Lifshitz 8d0a4a1874 Fix delayed log interpolation false positives
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
2023-04-25 10:50:41 -04:00
Balazs Gibizer 3fde1e570a Bump flake8 to 5.0 to pick up fixes
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
2023-02-17 14:18:44 -05:00
Balazs Gibizer 52b9f4f110 Make tox.ini 4.0 compatible
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
2023-02-14 19:12:27 +01:00
Balazs Gibizer 2931131b69 Drop py36 and py37 support
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
2022-06-10 11:18:33 +02:00
Stephen Finucane a6b9aabca5 Add support for flake8 4.x
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>
2022-06-03 11:42:50 +02:00
Dr. Jens Harbott b75c7e6b25 Fix test errors with python3.10
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
2022-03-28 08:37:02 +02:00
LiZekun e3071cdc4b Use TOX_CONSTRAINTS_FILE
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
2022-03-25 11:23:48 +01:00
Zuul 8e26e603ec Merge "Fix unconditional license print if H103 is not selected" 2022-03-25 10:17:00 +00:00
Stephen Finucane a787403f0c Update CI to use unversioned jobs template
As part of the migration of this project to the independent release
model, we failed to notice that the job template was still tied to a
specific release. We've now introduced a new unversioned job template,
'openstack-python3-jobs' [1], which was can and should use. Do this.

[1] https://review.opendev.org/c/openstack/openstack-zuul-jobs/+/833286/

Change-Id: Ibad67323f0b5f2a3b7985d16eecb3db26511986c
Depends-On: https://review.opendev.org/c/openstack/openstack-zuul-jobs/+/833286/
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2022-03-15 15:05:57 +00:00
Ilya Maximets ab5de186cf Fix unconditional license print if H103 is not selected
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
2022-02-23 01:12:15 +01:00
LiZekun e42996fea9 Update python testing classifier
Change-Id: If14b32f198447336b5844491e2dd6a3480b68a9d
2022-01-10 17:18:37 +08:00
LiZekun 6763c87d68 remove unicode from code
Change-Id: I4e325e9775f07a9052b92be33724cc794d8bfdcb
2022-01-10 17:10:15 +08:00
Martin Kopec 8656c3e798 Switch testing to Yoga testing runtime
Upating the tetsing template to Yoga testing runtime:
https://governance.openstack.org/tc/reference/runtimes/yoga.html

Change-Id: Ibe4eb880df34768f989036cba94c3ba098f60370
2021-10-07 08:43:54 +00:00
Zuul f11b009e15 Merge "setup.cfg: Replace dashes with underscores" 2021-06-05 10:03:49 +00:00
Anand Bhat 50f6cbea13 setup.cfg: Replace dashes with underscores
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
2021-06-02 16:14:51 +05:30
Ghanshyam Mann 8809c3405b Update IRC network to OFTC
Change-Id: I8a920e55c2c4b1c2c4d0f1f6e1f32fbbd7f77163
2021-05-31 15:05:41 -05:00
yangyawei 7a6141469e setup.cfg: Replace dashes with underscores
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
2021-05-03 10:35:11 +08:00
Martin Kopec fb275f7084 Switch testing to Xena testing runtime
Upating the tetsing template to Xena testing runtime:
https://governance.openstack.org/tc/reference/runtimes/xena.html

Change-Id: I3539e4dd0dfc1f138210d515aa5abc5cbb184826
2021-04-29 14:15:06 +00:00
Sorin Sbarnea dfb09fb055 Allow hacking to be used as a pre-commit hook
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
2021-04-01 15:10:52 +01:00
Sorin Sbarnea f56b276b97 Enable py39 testing with hacking
- 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
2021-03-30 11:24:46 +01:00
Sorin Sbarnea bb71c7271d Add useful project links to metadata
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
2021-03-30 11:18:48 +01:00
Ghanshyam Mann 11fef202d7 Drop lower bound testing
As discussed in ML and TC meeting, lower bound
testing is optional and its up to projects to
maintain it or drop it.

- http://lists.openstack.org/pipermail/openstack-discuss/2021-March/021204.html

Change-Id: I41f876ab7363f05a0f912a65d1484b10d5613a3e
2021-03-23 10:00:26 -05:00
tushargite96 65eee9782c Changed minversion in tox to 3.18.0
The patch bumps min version of tox to 3.18.0 python in order to
replace tox's whitelist_externals by allowlist_externals option:
https://github.com/tox-dev/tox/blob/master/docs/changelog.rst#v3180-2020-07-23

Change-Id: Ic73f1212d3a4a7178a7c735dae696bb9b8792d84
2021-02-25 23:08:54 +05:30
Zuul 213936559e Merge "Add H216 to flag use of third party mock" 2021-01-26 20:37:07 +00:00
Paras Babbar 5cfcdbc8d9 Updating lower-constarints job as non voting
There is an ongoing discussion in ML to drop the
lower-constraints job [1].

Moving it to Non-voting until any decision is being
made in TC meeting.

[1]: http://lists.openstack.org/pipermail/openstack-discuss/2021-January/019672.html

Change-Id: Ia091d020641766089786cf6995e0c7a92f159a84
2021-01-26 11:54:39 -05:00
Sean McGinnis b921c4de51 Add H216 to flag use of third party mock
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>
2020-12-01 14:23:27 -06:00
Ghanshyam Mann 4069b0c4f5 Add separate releasenotes page per version
Change-Id: I98b3b0e257172c6d43f5dd4b0d9147fc154bd5e6
2020-11-25 14:26:24 -06:00
Sean McGinnis f82f995d02
Catch .format() use in log string interpoliation check
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>
2020-10-13 12:05:00 -05:00
Sean McGinnis 31e9c8751e
Handle formatting of args in string interpolation check
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>
2020-10-13 12:00:16 -05:00
Zuul 711ca6eb60 Merge "Fix H903 hacking_no_cr" 2020-10-13 13:47:24 +00:00
Zuul 5eed32948b Merge "Fix H904 hacking_delayed_string_interpolation" 2020-10-13 13:47:23 +00:00
Paras Babbar bfc1a64ac6 Move the most common hacking rules from other projects
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
2020-09-29 23:57:52 +00:00
Sean McGinnis f70a450a7f Fix H903 hacking_no_cr
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>
2020-07-22 19:23:16 +00:00
Sean McGinnis 6002520ae3
Fix H904 hacking_delayed_string_interpolation
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>
2020-07-22 14:12:05 -05:00
Ghanshyam Mann 93e6cd2904 migrate testing to ubuntu focal
As per victoria cycle testing runtime and community goal[1]
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

Fixing:
- bug#1886296
Bump the flake8 to 3.8.0 as min so that pyflakes 2.1.1 as min version taken
care to run pep8 jobs on py3.8 which is default python vesion in ubuntu focal.
- https://github.com/PyCQA/flake8/blob/3.8.0/setup.cfg#L44

Story: #2007865
Task: #40212

Closes-Bug: #1886296
[1] https://governance.openstack.org/tc/goals/selected/victoria/migrate-ci-cd-jobs-to-ubuntu-focal.html

Change-Id: I19b13d5d63bce0f6b646972b09cfe8e8d7c22adc
2020-07-10 14:29:26 +00:00
Hervé Beraud 46c876fef2 drop mock from lower-constraints and requirements
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
2020-06-09 01:11:19 +02:00
Zuul b5683a0534 Merge "Switch to newer openstackdocstheme and reno versions" 2020-06-04 15:21:16 +00:00
Zuul 0e4b1faa2b Merge "Add PDF documentation build" 2020-06-04 15:21:11 +00:00
Ghanshyam Mann 3c289f86ea Add in-tree upper-constraints for py35 job
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
2020-05-26 18:57:50 +00:00
Ghanshyam Mann ce8d260600 Revert "Remove py35 job"
This partially reverts commit 7d4963306f.

Depends-On: https://review.opendev.org/#/c/729306/

Change-Id: Ic5605724f914b23aa485b1355e8f8dd25b051d86
2020-05-26 18:57:37 +00:00
Andreas Jaeger 4d84a3b496 Switch to newer openstackdocstheme and reno versions
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
2020-05-22 17:27:39 +00:00