summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-01-26 12:11:58 +0100
committerMichał Górny <mgorny@gentoo.org>2023-01-26 12:12:32 +0100
commit91a00510cecc4e79ab1430cae5b6cfcfe9931611 (patch)
treefba738b660a13882b6f7e9b4dba6f8542bbe62a5
parentsci-physics/geant4_vmc: drop 5.4, 6.0-r1, 6.1 (diff)
downloadgentoo-91a00510cecc4e79ab1430cae5b6cfcfe9931611.tar.gz
gentoo-91a00510cecc4e79ab1430cae5b6cfcfe9931611.tar.bz2
gentoo-91a00510cecc4e79ab1430cae5b6cfcfe9931611.zip
dev-python/python-lsp-black: Port to tomllib/tomli
Closes: https://bugs.gentoo.org/878669 Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--dev-python/python-lsp-black/files/python-lsp-black-1.2.1-tomli.patch94
-rw-r--r--dev-python/python-lsp-black/python-lsp-black-1.2.1-r1.ebuild (renamed from dev-python/python-lsp-black/python-lsp-black-1.2.1.ebuild)8
2 files changed, 101 insertions, 1 deletions
diff --git a/dev-python/python-lsp-black/files/python-lsp-black-1.2.1-tomli.patch b/dev-python/python-lsp-black/files/python-lsp-black-1.2.1-tomli.patch
new file mode 100644
index 000000000000..8ecef0287f40
--- /dev/null
+++ b/dev-python/python-lsp-black/files/python-lsp-black-1.2.1-tomli.patch
@@ -0,0 +1,94 @@
+From 80d34ca4f35baa654e5f1fee7860214950f1ae37 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Thu, 26 Jan 2023 12:07:11 +0100
+Subject: [PATCH] Replace the obsolete toml package with tomllib/tomli
+
+Use the modern `tomllib` module (in Python 3.11+) or its drop-in
+replacement `tomli` (for older Python versions) instead of the obsolete
+`toml` module. The latter is unmaintained and does not support TOML
+1.0.
+---
+ .pre-commit-config.yaml | 2 +-
+ pylsp_black/plugin.py | 12 +++++++++---
+ setup.cfg | 7 +++++--
+ 3 files changed, 15 insertions(+), 6 deletions(-)
+
+diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
+index 304770e..d5bd147 100644
+--- a/.pre-commit-config.yaml
++++ b/.pre-commit-config.yaml
+@@ -17,7 +17,7 @@ repos:
+ rev: v0.942
+ hooks:
+ - id: mypy
+- additional_dependencies: [black, types-pkg_resources, types-setuptools, types-toml]
++ additional_dependencies: [black, types-pkg_resources, types-setuptools]
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.1.0
+ hooks:
+diff --git a/pylsp_black/plugin.py b/pylsp_black/plugin.py
+index f013171..090b1b0 100644
+--- a/pylsp_black/plugin.py
++++ b/pylsp_black/plugin.py
+@@ -1,15 +1,20 @@
+ import logging
+ import os
++import sys
+ from functools import lru_cache
+ from pathlib import Path
+ from typing import Dict, Optional
+
+ import black
+-import toml
+ from pylsp import hookimpl
+ from pylsp._utils import get_eol_chars
+ from pylsp.config.config import Config
+
++if sys.version_info >= (3, 11):
++ import tomllib
++else:
++ import tomli as tomllib
++
+ logger = logging.getLogger(__name__)
+
+
+@@ -154,8 +159,9 @@ def _load_config(filename: str, client_config: Config) -> Dict:
+ return defaults
+
+ try:
+- pyproject_toml = toml.load(str(pyproject_filename))
+- except (toml.TomlDecodeError, OSError):
++ with open(pyproject_filename, "rb") as f:
++ pyproject_toml = tomllib.load(f)
++ except (tomllib.TOMLDecodeError, OSError):
+ logger.warning(
+ "Error decoding pyproject.toml, using defaults: %r",
+ defaults,
+diff --git a/setup.cfg b/setup.cfg
+index 47510d5..257add6 100644
+--- a/setup.cfg
++++ b/setup.cfg
+@@ -18,7 +18,10 @@ classifiers =
+
+ [options]
+ packages = find:
+-install_requires = python-lsp-server>=1.4.0; black>=22.3.0; toml
++install_requires =
++ python-lsp-server>=1.4.0
++ black>=22.3.0
++ tomli; python_version<'3.11'
+ python_requires = >= 3.7
+
+ [options.entry_points]
+@@ -26,7 +29,7 @@ pylsp = pylsp_black = pylsp_black.plugin
+
+ [options.extras_require]
+ # add any types-* packages to .pre-commit-config.yaml mypy additional_dependencies
+-dev = isort>=5.0; flake8; pre-commit; pytest; mypy; pytest; types-pkg_resources; types-setuptools; types-toml
++dev = isort>=5.0; flake8; pre-commit; pytest; mypy; pytest; types-pkg_resources; types-setuptools
+
+ [flake8]
+ max-line-length = 88
+--
+2.39.1
+
diff --git a/dev-python/python-lsp-black/python-lsp-black-1.2.1.ebuild b/dev-python/python-lsp-black/python-lsp-black-1.2.1-r1.ebuild
index b14d4254f151..72414f29252b 100644
--- a/dev-python/python-lsp-black/python-lsp-black-1.2.1.ebuild
+++ b/dev-python/python-lsp-black/python-lsp-black-1.2.1-r1.ebuild
@@ -29,8 +29,14 @@ RDEPEND="
BDEPEND="
test? (
- dev-python/toml[${PYTHON_USEDEP}]
+ $(python_gen_cond_dep '
+ dev-python/tomli[${PYTHON_USEDEP}]
+ ' 3.{8..10})
)
"
distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}"/${P}-tomli.patch
+)