commit:     aa8da0c8d86b04859bf4f3f944bffbef1b772914
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 26 14:32:54 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Jan 26 14:33:21 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aa8da0c8

dev-python/pylama: Port to tomllib/tomli

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/pylama/files/pylama-8.4.1-tomli.patch   | 69 ++++++++++++++++++++++
 ...{pylama-8.4.1.ebuild => pylama-8.4.1-r1.ebuild} | 18 +++++-
 2 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/dev-python/pylama/files/pylama-8.4.1-tomli.patch 
b/dev-python/pylama/files/pylama-8.4.1-tomli.patch
new file mode 100644
index 000000000000..291bc9f530e7
--- /dev/null
+++ b/dev-python/pylama/files/pylama-8.4.1-tomli.patch
@@ -0,0 +1,69 @@
+From 8b7908fec960a05af0a0a9b10d24ed458fcf97c7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
+Date: Tue, 8 Nov 2022 14:33:59 +0100
+Subject: [PATCH] Use tomli/tomllib instead of the unmaintained toml package
+
+Replace the use of the unmaintained `toml` package with the modern
+alternatives: the built-in `tomllib` in Python 3.11+, and its equivalent
+`tomli` in older Python versions.  `tomli` installs type stubs, so there
+is no need for an additional `types-*` package for it.
+---
+ pylama/config_toml.py               | 9 +++++++--
+ requirements/requirements-tests.txt | 3 +--
+ setup.py                            | 2 +-
+ 3 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/pylama/config_toml.py b/pylama/config_toml.py
+index 2af02a5..ea6e17a 100644
+--- a/pylama/config_toml.py
++++ b/pylama/config_toml.py
+@@ -1,16 +1,21 @@
+ """Pylama TOML configuration."""
+ 
+-import toml
++import sys
+ 
+ from pylama.libs.inirama import Namespace as _Namespace
+ 
++if sys.version_info >= (3, 11):
++    import tomllib
++else:
++    import tomli as tomllib
++
+ 
+ class Namespace(_Namespace):
+     """Inirama-style wrapper for TOML config."""
+ 
+     def parse(self, source: str, update: bool = True, **params):
+         """Parse TOML source as string."""
+-        content = toml.loads(source)
++        content = tomllib.loads(source)
+         tool = content.get("tool", {})
+         pylama = tool.get("pylama", {})
+         linters = pylama.pop("linter", {})
+diff --git a/requirements/requirements-tests.txt 
b/requirements/requirements-tests.txt
+index d786f1f..e62ccae 100644
+--- a/requirements/requirements-tests.txt
++++ b/requirements/requirements-tests.txt
+@@ -5,8 +5,7 @@ radon       >= 5.1.0
+ mypy
+ pylint      >= 2.11.1
+ pylama-quotes
+-toml
++tomli       >= 1.2.3  ; python_version < "3.11"
+ vulture
+ 
+ types-setuptools
+-types-toml
+diff --git a/setup.py b/setup.py
+index 911aea6..6d0222b 100644
+--- a/setup.py
++++ b/setup.py
+@@ -21,6 +21,6 @@ def parse_requirements(path: str) -> "list[str]":
+     extras_require=dict(
+         tests=parse_requirements("requirements/requirements-tests.txt"),
+         all=OPTIONAL_LINTERS, **{linter: [linter] for linter in 
OPTIONAL_LINTERS},
+-        toml="toml>=0.10.2",
++        toml="tomli>=1.2.3; python_version < '3.11'",
+     ),
+ )

diff --git a/dev-python/pylama/pylama-8.4.1.ebuild 
b/dev-python/pylama/pylama-8.4.1-r1.ebuild
similarity index 75%
rename from dev-python/pylama/pylama-8.4.1.ebuild
rename to dev-python/pylama/pylama-8.4.1-r1.ebuild
index 0d21af8a8555..c1a76432c6e9 100644
--- a/dev-python/pylama/pylama-8.4.1.ebuild
+++ b/dev-python/pylama/pylama-8.4.1-r1.ebuild
@@ -9,8 +9,14 @@ PYTHON_COMPAT=( python3_{9..11} )
 inherit distutils-r1
 
 DESCRIPTION="Code audit tool for python"
-HOMEPAGE="https://github.com/klen/pylama";
-SRC_URI="https://github.com/klen/pylama/archive/${PV}.tar.gz -> ${P}.gh.tar.gz"
+HOMEPAGE="
+       https://github.com/klen/pylama/
+       https://pypi.org/project/pylama/
+"
+SRC_URI="
+       https://github.com/klen/pylama/archive/${PV}.tar.gz
+               -> ${P}.gh.tar.gz
+"
 
 LICENSE="MIT"
 SLOT="0"
@@ -28,13 +34,19 @@ BDEPEND="
                dev-python/mypy[${PYTHON_USEDEP}]
                dev-python/pylint[${PYTHON_USEDEP}]
                dev-python/radon[${PYTHON_USEDEP}]
-               dev-python/toml[${PYTHON_USEDEP}]
                dev-vcs/git
+               $(python_gen_cond_dep '
+                       dev-python/tomli[${PYTHON_USEDEP}]
+               ' 3.{8..10})
        )
 "
 
 distutils_enable_tests pytest
 
+PATCHES=(
+       "${FILESDIR}"/${P}-tomli.patch
+)
+
 EPYTEST_DESELECT=(
        # not packaged
        tests/test_linters.py::test_quotes

Reply via email to