From 643a58e255503161a94a591e2fd32bb0eaaefb8f Mon Sep 17 00:00:00 2001 From: Vsevolod Fedorov Date: Tue, 29 Oct 2024 13:55:06 +0300 Subject: [PATCH] Fix zuul checks Fix docs and docs-linkcheck tox targets: It looks like recently sphinx began to check if footnotes are referenced. If not, it issues a warning which is treated as error. Fix Python 3.10 and 3.11: It looks like opendev switched to Noble Ubuntu release. Pin these versions to previous one. Shift flake8 version. New version ignores syntax whithin strings. Fix formatting errors reported by flake8. Change-Id: I9b23cccf0dc83fb56083b5fe8c9c026f5dff7e9a --- .pre-commit-config.yaml | 4 ++-- .zuul.yaml | 12 ++++++++---- doc/source/execution.rst | 2 +- jenkins_jobs/dimensions.py | 2 +- jenkins_jobs/errors.py | 2 +- jenkins_jobs/modules/helpers.py | 2 +- jenkins_jobs/modules/project_multibranch.py | 2 +- jenkins_jobs/modules/publishers.py | 2 +- jenkins_jobs/modules/scm.py | 2 +- 9 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1679b0569..88ec37f09 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,13 +13,13 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/PyCQA/flake8 - rev: 3.7.8 + rev: 6.1.0 hooks: - id: flake8 args: ['--config=setup.cfg'] types: [python] additional_dependencies: - - flake8>=3.7.8 + - flake8>=6.1.0 - flake8-black - black==21.12b0 # the last version that supports Python 2 language_version: python3 diff --git a/.zuul.yaml b/.zuul.yaml index 1d1e3e3f0..baf422c15 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -32,8 +32,10 @@ nodeset: ubuntu-focal - tox-py39: nodeset: ubuntu-focal - - tox-py310 - - tox-py311 + - tox-py310: + nodeset: ubuntu-jammy + - tox-py311: + nodeset: ubuntu-jammy - jjb-tox-linters - jjb-tox-cross-python-jenkins - jjb-tox-docs-linkcheck @@ -44,5 +46,7 @@ nodeset: ubuntu-focal - tox-py39: nodeset: ubuntu-focal - - tox-py310 - - tox-py311 + - tox-py310: + nodeset: ubuntu-jammy + - tox-py311: + nodeset: ubuntu-jammy diff --git a/doc/source/execution.rst b/doc/source/execution.rst index c9b256972..f0de9bf89 100644 --- a/doc/source/execution.rst +++ b/doc/source/execution.rst @@ -350,7 +350,7 @@ To delete jobs/views that only have 'foo' in their name:: Providing Plugins Info ^^^^^^^^^^^^^^^^^^^^^^ With Jenkins LTS 1.651.1+ retrieving plugins info became a secure feature and -now requires Administrator rights to use [#f2]. This causes JJB to no longer be +now requires Administrator rights to use [#f2]_. This causes JJB to no longer be able to work in situations where a user wants to publish jobs to Jenkins but is not able to receive the Administrator permissions. In this case we can provide a plugins_info.yaml file containing the plugin versions data needed by JJB to diff --git a/jenkins_jobs/dimensions.py b/jenkins_jobs/dimensions.py index 3e67afcf3..18f293fe8 100644 --- a/jenkins_jobs/dimensions.py +++ b/jenkins_jobs/dimensions.py @@ -114,7 +114,7 @@ def is_point_included(exclude_list, params, key_pos=None): return False except JenkinsJobsException as x: raise x.with_context( - f"In template exclude list", + "In template exclude list", pos=key_pos, ) return True diff --git a/jenkins_jobs/errors.py b/jenkins_jobs/errors.py index cd46950c5..4bc092b86 100644 --- a/jenkins_jobs/errors.py +++ b/jenkins_jobs/errors.py @@ -17,7 +17,7 @@ def context_lines(message, pos): return [message] snippet_lines = [line.rstrip() for line in pos.snippet.splitlines()] return [ - f"{pos.path}:{pos.line+1}:{pos.column+1}: {message}", + f"{pos.path}:{pos.line + 1}:{pos.column + 1}: {message}", *snippet_lines, ] diff --git a/jenkins_jobs/modules/helpers.py b/jenkins_jobs/modules/helpers.py index e8f568fed..a15858203 100644 --- a/jenkins_jobs/modules/helpers.py +++ b/jenkins_jobs/modules/helpers.py @@ -692,7 +692,7 @@ def convert_mapping_to_xml(parent, data, mapping, fail_required=True): if val not in valid_options: raise InvalidAttributeError(optname, val, valid_options) - if type(val) == bool: + if type(val) is bool: val = str(val).lower() if val in valid_dict: diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py index 81395a33f..ad4060c2d 100644 --- a/jenkins_jobs/modules/project_multibranch.py +++ b/jenkins_jobs/modules/project_multibranch.py @@ -2053,7 +2053,7 @@ def add_notification_context_trait(traits, data): nc_suffix = nc.get("suffix", None) if nc_suffix is None: nc_trait_suffix.text = "true" - elif type(nc_suffix) == bool: + elif type(nc_suffix) is bool: nc_trait_suffix.text = str(nc_suffix).lower() else: nc_trait_suffix.text = nc_suffix diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 27e5f59f3..9e8f1dbc2 100755 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -916,7 +916,7 @@ def cloverphp(registry, xml_parent, data): for t_type in ["method", "statement"]: val = metrics.get(target, {}).get(t_type) - if val is None or type(val) != int: + if val is None or type(val) is not int: continue if val < 0 or val > 100: raise JenkinsJobsException( diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index a50145449..5b427c240 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -420,7 +420,7 @@ def git(registry, xml_parent, data): xe = XML.SubElement(scm, xmlname, attrs) if optname and optname in data: val = data[optname] - if type(val) == bool: + if type(val) is bool: xe.text = str(val).lower() else: xe.text = val