Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any version of Python (including 3.11) in metadata #2742

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions kedro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,26 @@
configuration and pipeline assembly.
"""

import sys
import warnings

__version__ = "0.18.11"


class KedroPythonVersionWarning(UserWarning):
"""Custom class for warnings about incompatibilities with Python versions."""

pass


if not sys.warnoptions:
warnings.simplefilter("error", KedroPythonVersionWarning)

if sys.version_info >= (3, 11):
warnings.warn(
"""Kedro is not yet fully compatible with this Python version.
To proceed at your own risk and ignore this warning,
run Kedro with `python -W "default:Kedro is not yet fully compatible" -m kedro ...`
or set the PYTHONWARNINGS environment variable accordingly.""",
KedroPythonVersionWarning,
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
{name = "Kedro"}
]
description = "Kedro helps you build production-ready data and analytics pipelines"
requires-python = ">=3.7, <3.11"
requires-python = ">=3.7"
keywords = [
"pipelines",
"machine learning",
Expand Down
27 changes: 27 additions & 0 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

import kedro


def test_import_kedro_with_no_official_support_raise_error(mocker):
"""Test importing kedro with python>=3.11 should fail"""
mocker.patch("kedro.sys.version_info", (3, 11))

# We use the parent class to avoid issues with `exec_module`
with pytest.raises(UserWarning) as excinfo:
kedro.__loader__.exec_module(kedro)

assert "Kedro is not yet fully compatible" in str(excinfo.value)


def test_import_kedro_with_no_official_support_emits_warning(mocker):
"""Test importing kedro python>=3.11 and controlled warnings should work"""
mocker.patch("kedro.sys.version_info", (3, 11))
mocker.patch("kedro.sys.warnoptions", ["default:Kedro is not yet fully compatible"])

# We use the parent class to avoid issues with `exec_module`
with pytest.warns(UserWarning) as record:
kedro.__loader__.exec_module(kedro)

assert len(record) == 1
assert "Kedro is not yet fully compatible" in record[0].message.args[0]