diff --git a/CHANGELOG.md b/CHANGELOG.md index 8848d22fd9..cf5655cded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ #### Deprecations +- Deprecated warnings will be triggered when using snowpark-python with Python 3.9. For more details, please refer to https://docs.snowflake.com/en/developer-guide/python-runtime-support-policy. + #### Dependency Updates #### Improvements diff --git a/src/snowflake/snowpark/__init__.py b/src/snowflake/snowpark/__init__.py index dd9fa994d3..1f6633086c 100644 --- a/src/snowflake/snowpark/__init__.py +++ b/src/snowflake/snowpark/__init__.py @@ -91,10 +91,24 @@ "the Snowflake team. For more details, please refer " "to https://docs.snowflake.com/en/developer-guide/python-runtime-support-policy." ) +_deprecation_warning_msg_for_3_9 = ( + "Python Runtime 3.9 reached its End-Of-Life (EOL) in October 2025, there will be no further bug fixes " + "or security updates for this runtime. We recommend that you upgrade your existing Python 3.9 objects to " + "Python 3.10, 3.11, 3.12 or 3.13. Please note that end of support does not impact execution, " + "and you will still be able to update and invoke existing objects. " + "However, they will be running on an unsupported runtime which will no longer be maintained or patched by " + "the Snowflake team. For more details, please refer " + "to https://docs.snowflake.com/en/developer-guide/python-runtime-support-policy." +) + warnings.filterwarnings( "once", # ensure the warning is only shown once to avoid warning explosion message=_deprecation_warning_msg, ) +warnings.filterwarnings( + "once", + message=_deprecation_warning_msg_for_3_9, +) if sys.version_info.major == 3 and sys.version_info.minor == 8: warnings.warn( @@ -102,3 +116,10 @@ category=DeprecationWarning, stacklevel=2, ) + +if sys.version_info.major == 3 and sys.version_info.minor == 9: + warnings.warn( + _deprecation_warning_msg_for_3_9, + category=DeprecationWarning, + stacklevel=2, + ) diff --git a/tests/unit/test_deprecation.py b/tests/unit/test_deprecation.py index 64e11a202c..fb01542e1f 100644 --- a/tests/unit/test_deprecation.py +++ b/tests/unit/test_deprecation.py @@ -25,3 +25,21 @@ def test_py38_deprecation(): with pytest.warns(None) as record: importlib.import_module("snowflake.snowpark") assert len(record) == 0 + + +def test_py39_deprecation(): + if not (sys.version_info.major == 3 and sys.version_info.minor == 9): + pytest.skip("This test is for Python 3.9 only") + + with pytest.warns( + DeprecationWarning, + match="Python Runtime 3.9 reached its End-Of-Life", + ) as record: + importlib.reload(snowflake.snowpark) + + assert len(record) == 1 + + # import again won't trigger the warning + with pytest.warns(None) as record: + importlib.import_module("snowflake.snowpark") + assert len(record) == 0