From 2671568d60ad19aad3db69f867d077731e6de5c4 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sun, 31 Mar 2024 18:48:13 +0200 Subject: [PATCH] MAINT update the python version supported (#1073) --- doc/whats_new/v0.12.rst | 8 +++++++- imblearn/utils/tests/test_docstring.py | 17 +++++++++++++++++ setup.py | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/whats_new/v0.12.rst b/doc/whats_new/v0.12.rst index bc707ae8c..741b9173e 100644 --- a/doc/whats_new/v0.12.rst +++ b/doc/whats_new/v0.12.rst @@ -19,7 +19,13 @@ Compatibility ............. - Do not use `distutils` in tests due to deprecation. - :pr:`1065` by :user:`Michael R. Crusoe ` + :pr:`1065` by :user:`Michael R. Crusoe `. + +- Fix the scikit-learn import in tests to be compatible with version 1.4.1.post1. + :pr:`1073` by :user:`Guillaume Lemaitre `. + +- Fix test to be compatible with Python 3.13. + :pr:`1073` by :user:`Guillaume Lemaitre `. Version 0.12.0 ============== diff --git a/imblearn/utils/tests/test_docstring.py b/imblearn/utils/tests/test_docstring.py index 0109fdb31..133701f8d 100644 --- a/imblearn/utils/tests/test_docstring.py +++ b/imblearn/utils/tests/test_docstring.py @@ -3,11 +3,23 @@ # Authors: Guillaume Lemaitre # License: MIT +import sys +import textwrap + import pytest from imblearn.utils import Substitution from imblearn.utils._docstring import _n_jobs_docstring, _random_state_docstring + +def _dedent_docstring(docstring): + """Compatibility with Python 3.13+. + + xref: https://github.com/python/cpython/issues/81283 + """ + return "\n".join([textwrap.dedent(line) for line in docstring.split("\n")]) + + func_docstring = """A function. Parameters @@ -55,6 +67,11 @@ def __init__(self, param_1, param_2): self.param_2 = param_2 +if sys.version_info.minor == "13": + func_docstring = _dedent_docstring(func_docstring) + cls_docstring = _dedent_docstring(cls_docstring) + + @pytest.mark.parametrize( "obj, obj_docstring", [(func, func_docstring), (cls, cls_docstring)] ) diff --git a/setup.py b/setup.py index f7856666a..5e26c3480 100755 --- a/setup.py +++ b/setup.py @@ -49,10 +49,10 @@ "Operating System :: POSIX", "Operating System :: Unix", "Operating System :: MacOS", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] PYTHON_REQUIRES = ">=3.8" INSTALL_REQUIRES = (min_deps.tag_to_packages["install"],)