dev-python/faker: Enable py3.14

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny 2025-05-14 10:33:21 +02:00
parent c2237ca59c
commit b038c00e3e
No known key found for this signature in database
GPG Key ID: 639ADAE2329E240E
2 changed files with 51 additions and 1 deletions

View File

@ -5,7 +5,7 @@ EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYPI_PN=${PN^}
PYTHON_COMPAT=( pypy3 pypy3_11 python3_{10..13} )
PYTHON_COMPAT=( pypy3_11 python3_{11..14} )
inherit distutils-r1 pypi
@ -34,6 +34,11 @@ BDEPEND="
# note: tests are flaky with xdist
distutils_enable_tests pytest
PATCHES=(
# https://github.com/joke2k/faker/pull/2213
"${FILESDIR}/${P}-py314.patch"
)
python_test() {
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
local -x PYTEST_PLUGINS=faker.contrib.pytest.plugin

View File

@ -0,0 +1,45 @@
From eaad7bb42385793a0622376caf3b832a7836781e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Wed, 14 May 2025 13:17:48 +0200
Subject: [PATCH] Fix type annotations for Python 3.14
Fix type annotations for `Provider.json()` to avoid name collision
in Python 3.14.0b1 where `json` is resolved to the `json()` method
itself rather than the `json` module. Import `JSONEncoder` directly
instead, so we can reference it without `json.`.
Fixes #2212
---
faker/providers/misc/__init__.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/faker/providers/misc/__init__.py b/faker/providers/misc/__init__.py
index dca3363e..6ed2e958 100644
--- a/faker/providers/misc/__init__.py
+++ b/faker/providers/misc/__init__.py
@@ -9,6 +9,7 @@ import tarfile
import uuid
import zipfile
+from json import JSONEncoder
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Set, Tuple, Type, Union, overload
from faker.exceptions import UnsupportedFeature
@@ -536,7 +537,7 @@ class Provider(BaseProvider):
data_columns: Optional[List] = None,
num_rows: int = 10,
indent: Optional[int] = None,
- cls: Optional[Type[json.JSONEncoder]] = None,
+ cls: Optional[Type[JSONEncoder]] = None,
) -> bytes:
"""
Generate random JSON structure and return as bytes.
@@ -551,7 +552,7 @@ class Provider(BaseProvider):
data_columns: Optional[List] = None,
num_rows: int = 10,
indent: Optional[int] = None,
- cls: Optional[Type[json.JSONEncoder]] = None,
+ cls: Optional[Type[JSONEncoder]] = None,
) -> str:
"""
Generate random JSON structure values.