From af38d825b76baa04a991adc896c923f4d4bd5b5a Mon Sep 17 00:00:00 2001 From: Eneko Martin-Martinez Date: Tue, 1 Aug 2023 11:45:51 +0200 Subject: [PATCH] Add future warning for Python 3.7 deprecation --- docs/whats_new.rst | 5 +++-- pysd/py_backend/utils.py | 7 ------- pysd/pysd.py | 16 ++++++++++++++-- tests/pytest.ini | 3 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/whats_new.rst b/docs/whats_new.rst index afd07970..24b4676f 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -1,7 +1,7 @@ What's New ========== -v3.11.0 (2023/07) ------------------ +v3.11.0 (2023/08/01) +-------------------- New Features ~~~~~~~~~~~~ - Add the possibility to run a model one or several steps at a time, updating model variables in the process. (`@rogersamso `_) @@ -28,6 +28,7 @@ Internal Changes - Add the :py:meth:`pysd.py_backend.output.ModelOutput.collect` method to the :py:class:`pysd.py_backend.output.ModelOutput` class. (`@rogersamso `_) - Add the :py:meth:`pysd.py_backend.model.Model.set_stepper` and :py:meth:`pysd.py_backend.model.Model.step` methods to the :py:class:`pysd.py_backend.model.Model` class. (`@rogersamso `_) - Add several internal methods to the :py:class:`pysd.py_backend.model.Model` class, to avoid code repetition. (`@rogersamso `_) +- Add :py:class:`FutureWarning` for Python 3.7 support deprecation. (`@enekomartinmartinez `_) v3.10.0 (2023/04/28) diff --git a/pysd/py_backend/utils.py b/pysd/py_backend/utils.py index 241564c3..cad07937 100644 --- a/pysd/py_backend/utils.py +++ b/pysd/py_backend/utils.py @@ -134,13 +134,6 @@ def compute_shape(coords, reshape_len=None, py_name=""): shape: list Shape of the ordered dictionary or of the desired table or vector. - Note - ---- - Dictionaries in Python >= 3.7 are ordered, which means that - we could remove dims if there is a not backward compatible - version of the library which only works in Python 3.7+. For now, - the dimensions list is passed to make it work properly for all the users. - """ if not reshape_len: return [len(coord) for coord in coords.values()] diff --git a/pysd/pysd.py b/pysd/pysd.py index 1c0f9467..ad1f9dfc 100644 --- a/pysd/pysd.py +++ b/pysd/pysd.py @@ -6,6 +6,7 @@ """ import sys +from warnings import warn from pysd.py_backend.model import Model @@ -14,14 +15,25 @@ raise RuntimeError( "\n\n" + "Your Python version is no longer supported by PySD.\n" - + "The current version needs to run at least Python 3.7." + + "The current version needs to run at least Python 3.7" + + "(we recommend running at least Python 3.8)." + " You are running:\n\tPython " + sys.version - + "." + "\nPlease update your Python version or use the last " + " supported version:\n\t" + "https://github.com/SDXorg/pysd/releases/tag/LastPy2" ) +elif sys.version_info[:2] == (3, 7): # pragma: no cover + warn( + "\n\n" + + "Python 3.7 will no longer be supported by PySD in future " + + "releases.\n" + + " You are running:\n\tPython " + + sys.version + + "\nPlease update your Python version to 3.8 or higher to " + + " be able to continue running PySD in the future.", + FutureWarning + ) def read_xmile(xmile_file, data_files=None, initialize=True, diff --git a/tests/pytest.ini b/tests/pytest.ini index 432443bb..99288fb4 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -7,4 +7,5 @@ filterwarnings = ignore:SelectableGroups dict interface is deprecated. Use select.:DeprecationWarning ignore:tostring\(\) is deprecated. Use tobytes\(\) instead.:DeprecationWarning ignore:distutils Version classes are deprecated. Use packaging.version instead.:DeprecationWarning - ignore:numpy.ndarray size changed, may indicate binary incompatibility.:RuntimeWarning + ignore:numpy.ndarray size changed, may indicate binary incompatibility.:RuntimeWarning + ignore:\n\nPython 3.7 will no longer be supported by PySD in future releases.:FutureWarning