This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-7-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 701ac6de95c207b0b744f6685ff4eaf07c8a0ee6 Author: starone <[email protected]> AuthorDate: Sun Sep 17 02:12:19 2023 +0900 Deprecate numeric type python version in PythonVirtualEnvOperator (#34359) * Remove float type python version in PythonVirtualEnvOperator Remove float type python version in PythonVirtualEnvOperator * Remove int type python version in PythonVirtualEnvOperator * change deprecated to removed change deprecated to removed * change removal to deprecation change removal to deprecation * fix typo fix typo * fix line too long fix line too long * change condition statement change condition statement * Use 'is not' --------- Co-authored-by: kyeonghoon Kim <[email protected]> Co-authored-by: Tzu-ping Chung <[email protected]> (cherry picked from commit b23d3f964b2699d4c7f579e22d50fabc9049d1b6) --- airflow/operators/python.py | 9 ++++++++- tests/operators/test_python.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/airflow/operators/python.py b/airflow/operators/python.py index 50cad387ad..1f0baec609 100644 --- a/airflow/operators/python.py +++ b/airflow/operators/python.py @@ -531,7 +531,7 @@ class PythonVirtualenvOperator(_BasePythonVirtualenvOperator): *, python_callable: Callable, requirements: None | Iterable[str] | str = None, - python_version: str | int | float | None = None, + python_version: str | None = None, use_dill: bool = False, system_site_packages: bool = True, pip_install_options: list[str] | None = None, @@ -554,6 +554,13 @@ class PythonVirtualenvOperator(_BasePythonVirtualenvOperator): "major versions for PythonVirtualenvOperator. Please use string_args." f"Sys version: {sys.version_info}. Venv version: {python_version}" ) + if python_version is not None and not isinstance(python_version, str): + warnings.warn( + "Passing non-string types (e.g. int or float) as python_version " + "is deprecated. Please use string value instead.", + RemovedInAirflow3Warning, + stacklevel=2, + ) if not is_venv_installed(): raise AirflowException("PythonVirtualenvOperator requires virtualenv, please install it.") if not requirements: diff --git a/tests/operators/test_python.py b/tests/operators/test_python.py index 28c70537ae..6a9a4058ce 100644 --- a/tests/operators/test_python.py +++ b/tests/operators/test_python.py @@ -963,7 +963,7 @@ class TestPythonVirtualenvOperator(BaseTestPythonVirtualenvOperator): return raise Exception - self.run_as_task(f, python_version=3, use_dill=False, requirements=["dill"]) + self.run_as_task(f, python_version="3", use_dill=False, requirements=["dill"]) def test_without_dill(self): def f(a):
