Skip to content

Commit

Permalink
Add future warning for Python 3.7 deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
enekomartinmartinez committed Aug 1, 2023
1 parent 1106672 commit af38d82
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
5 changes: 3 additions & 2 deletions docs/whats_new.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/rogersamso>`_)
Expand All @@ -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 <https://github.com/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 <https://github.com/rogersamso>`_)
- Add several internal methods to the :py:class:`pysd.py_backend.model.Model` class, to avoid code repetition. (`@rogersamso <https://github.com/rogersamso>`_)
- Add :py:class:`FutureWarning` for Python 3.7 support deprecation. (`@enekomartinmartinez <https://github.com/enekomartinmartinez>`_)


v3.10.0 (2023/04/28)
Expand Down
7 changes: 0 additions & 7 deletions pysd/py_backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand Down
16 changes: 14 additions & 2 deletions pysd/pysd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import sys
from warnings import warn

from pysd.py_backend.model import Model

Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tests/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit af38d82

Please sign in to comment.