From ecde638d7bf2760abe6472089cda20be58d4f7b4 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 26 Jan 2023 11:03:55 +0100 Subject: dev-python/bandit: Backport tomllib/tomli port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: https://bugs.gentoo.org/878661 Signed-off-by: Michał Górny --- dev-python/bandit/bandit-1.7.4-r1.ebuild | 46 +++++++++++++ dev-python/bandit/bandit-1.7.4.ebuild | 37 ----------- dev-python/bandit/files/bandit-1.7.4-tomli.patch | 85 ++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 37 deletions(-) create mode 100644 dev-python/bandit/bandit-1.7.4-r1.ebuild delete mode 100644 dev-python/bandit/bandit-1.7.4.ebuild create mode 100644 dev-python/bandit/files/bandit-1.7.4-tomli.patch (limited to 'dev-python/bandit') diff --git a/dev-python/bandit/bandit-1.7.4-r1.ebuild b/dev-python/bandit/bandit-1.7.4-r1.ebuild new file mode 100644 index 000000000000..769c2883561f --- /dev/null +++ b/dev-python/bandit/bandit-1.7.4-r1.ebuild @@ -0,0 +1,46 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{9..11} ) + +inherit distutils-r1 + +DESCRIPTION="A security linter from OpenStack Security" +HOMEPAGE=" + https://github.com/PyCQA/bandit/ + https://pypi.org/project/bandit/ +" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="amd64 ~arm arm64 ~riscv x86" + +RDEPEND=" + >=dev-python/pbr-2.0.0[${PYTHON_USEDEP}] + >=dev-python/GitPython-1.0.1[${PYTHON_USEDEP}] + >=dev-python/pyyaml-5.3.1[${PYTHON_USEDEP}] + >=dev-python/stevedore-1.20.0[${PYTHON_USEDEP}] +" +BDEPEND=" + >=dev-python/pbr-2.0.0[${PYTHON_USEDEP}] + test? ( + >=dev-python/fixtures-3.0.0[${PYTHON_USEDEP}] + >=dev-python/testscenarios-0.5.0[${PYTHON_USEDEP}] + >=dev-python/testtools-2.3.0[${PYTHON_USEDEP}] + >=dev-python/beautifulsoup4-4.8.0[${PYTHON_USEDEP}] + >=dev-python/pylint-1.9.4[${PYTHON_USEDEP}] + $(python_gen_cond_dep ' + dev-python/tomli[${PYTHON_USEDEP}] + ' 3.{8..10}) + ) +" + +distutils_enable_tests unittest + +PATCHES=( + "${FILESDIR}"/${P}-tomli.patch +) diff --git a/dev-python/bandit/bandit-1.7.4.ebuild b/dev-python/bandit/bandit-1.7.4.ebuild deleted file mode 100644 index cc946f6f00ff..000000000000 --- a/dev-python/bandit/bandit-1.7.4.ebuild +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 1999-2023 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -DISTUTILS_USE_PEP517=setuptools -PYTHON_COMPAT=( python3_{9..11} ) - -inherit distutils-r1 - -DESCRIPTION="A security linter from OpenStack Security" -HOMEPAGE="https://github.com/PyCQA/bandit" -SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" - -LICENSE="Apache-2.0" -SLOT="0" -KEYWORDS="amd64 ~arm arm64 ~riscv x86" - -RDEPEND=" - >=dev-python/pbr-2.0.0[${PYTHON_USEDEP}] - >=dev-python/GitPython-1.0.1[${PYTHON_USEDEP}] - >=dev-python/pyyaml-5.3.1[${PYTHON_USEDEP}] - >=dev-python/stevedore-1.20.0[${PYTHON_USEDEP}] -" -BDEPEND=" - >=dev-python/pbr-2.0.0[${PYTHON_USEDEP}] - test? ( - >=dev-python/fixtures-3.0.0[${PYTHON_USEDEP}] - >=dev-python/testscenarios-0.5.0[${PYTHON_USEDEP}] - >=dev-python/testtools-2.3.0[${PYTHON_USEDEP}] - >=dev-python/beautifulsoup4-4.8.0[${PYTHON_USEDEP}] - >=dev-python/pylint-1.9.4[${PYTHON_USEDEP}] - dev-python/toml[${PYTHON_USEDEP}] - ) -" - -distutils_enable_tests unittest diff --git a/dev-python/bandit/files/bandit-1.7.4-tomli.patch b/dev-python/bandit/files/bandit-1.7.4-tomli.patch new file mode 100644 index 000000000000..238cc1f6d352 --- /dev/null +++ b/dev-python/bandit/files/bandit-1.7.4-tomli.patch @@ -0,0 +1,85 @@ +From 5a8f1050011a6eeca96c1b8a0fe1988fda97f214 Mon Sep 17 00:00:00 2001 +From: Mathieu Kniewallner +Date: Fri, 25 Mar 2022 23:27:56 +0100 +Subject: [PATCH] Replace `toml` with `tomli` (#829) + +* Replace `toml` with `tomli` + +* Only require `tomli` on Python < 3.11 + +* Update test-requirements.txt + +Co-authored-by: Eric Brown +--- + bandit/core/config.py | 20 ++++++++++++-------- + setup.cfg | 2 +- + test-requirements.txt | 2 +- + 3 files changed, 14 insertions(+), 10 deletions(-) + +diff --git a/bandit/core/config.py b/bandit/core/config.py +index 7c259bcc..236f357c 100644 +--- a/bandit/core/config.py ++++ b/bandit/core/config.py +@@ -3,13 +3,17 @@ + # + # SPDX-License-Identifier: Apache-2.0 + import logging ++import sys + + import yaml + +-try: +- import toml +-except ImportError: +- toml = None ++if sys.version_info >= (3, 11): ++ import tomllib ++else: ++ try: ++ import tomli as tomllib ++ except ImportError: ++ tomllib = None + + from bandit.core import constants + from bandit.core import extension_loader +@@ -34,14 +38,14 @@ def __init__(self, config_file=None): + + if config_file: + try: +- f = open(config_file) ++ f = open(config_file, "rb") + except OSError: + raise utils.ConfigError( + "Could not read config file.", config_file + ) + + if config_file.endswith(".toml"): +- if toml is None: ++ if tomllib is None: + raise utils.ConfigError( + "toml parser not available, reinstall with toml extra", + config_file, +@@ -49,8 +53,8 @@ def __init__(self, config_file=None): + + try: + with f: +- self._config = toml.load(f)["tool"]["bandit"] +- except toml.TomlDecodeError as err: ++ self._config = tomllib.load(f)["tool"]["bandit"] ++ except tomllib.TOMLDecodeError as err: + LOG.error(err) + raise utils.ConfigError("Error parsing file.", config_file) + else: +diff --git a/setup.cfg b/setup.cfg +index 5d570eea..7449f15b 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -31,7 +31,7 @@ project_urls = + yaml = + PyYAML + toml = +- toml ++ tomli>=1.1.0; python_version < "3.11" + + [entry_points] + console_scripts = -- cgit v1.2.3-65-gdbad