From 79acf2fdd15be409652d4ae31bbd16c36c7d843a Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Mon, 10 Jul 2023 15:18:10 -0700 Subject: [PATCH] Deprecate Python 3.7 (#165) * deprecate python 3.7 * add types --- CHANGELOG.rst | 2 ++ pyproject.toml | 5 +++-- src/josepy/__init__.py | 10 ++++++++++ tests/init_test.py | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/init_test.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 75a84bc7..ab17b8cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ Changelog --------------- * Added support for Python 3.11. +* Support for Python 3.7 has been deprecated and will be removed in the next + scheduled release. * Dropped support for Python 3.6. * Added a new valid PGP key for signing our PyPI packages with the fingerprint F2871B4152AE13C49519111F447BF683AA3B26C3 diff --git a/pyproject.toml b/pyproject.toml index da51ca07..f07cc925 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - "Topic :: Internet :: WWW/HTTP", + "Topic :: Internet :: WWW/HTTP", "Topic :: Security", ] homepage = "https://github.com/certbot/josepy" @@ -94,7 +94,8 @@ disallow_untyped_defs = true # Pytest tooling configuration [tool.pytest.ini_options] -filterwarnings = ["error"] +# We also ignore our own deprecation warning about dropping Python 3.7 support. +filterwarnings = ["error", "ignore:Python 3.7 support will be dropped:DeprecationWarning"] norecursedirs = "*.egg .eggs dist build docs .tox" # Isort tooling configuration diff --git a/src/josepy/__init__.py b/src/josepy/__init__.py index efdcf64b..2abe7e53 100644 --- a/src/josepy/__init__.py +++ b/src/josepy/__init__.py @@ -25,6 +25,9 @@ .. _ACME: https://pypi.python.org/pypi/acme """ +import sys +import warnings + # flake8: noqa from josepy.b64 import b64decode, b64encode from josepy.errors import ( @@ -72,3 +75,10 @@ ComparableX509, ImmutableMap, ) + +if sys.version_info[:2] == (3, 7): + warnings.warn( + "Python 3.7 support will be dropped in the next scheduled release of " + "josepy. Please upgrade your Python version.", + DeprecationWarning, + ) diff --git a/tests/init_test.py b/tests/init_test.py new file mode 100644 index 00000000..8dac6465 --- /dev/null +++ b/tests/init_test.py @@ -0,0 +1,25 @@ +import importlib +import re +import sys +import warnings + +import pytest + +import josepy + + +@pytest.mark.skipif(sys.version_info[:2] != (3, 7), reason="requires Python 3.7") +def test_warns() -> None: + with pytest.warns(DeprecationWarning, match=re.escape(r"Python 3.7 support")): + importlib.reload(josepy) + + +@pytest.mark.skipif(sys.version_info[:2] == (3, 7), reason="requires Python != 3.7") +def test_does_not_warn() -> None: + with warnings.catch_warnings(): + warnings.simplefilter("error") + importlib.reload(josepy) + + +if __name__ == "__main__": + sys.exit(pytest.main(sys.argv[1:] + [__file__])) # pragma: no cover