You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ta...@apache.org on 2023/09/16 17:12:27 UTC
[airflow] branch main updated: Deprecate numeric type python version in PythonVirtualEnvOperator (#34359)
This is an automated email from the ASF dual-hosted git repository.
taragolis pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b23d3f964b Deprecate numeric type python version in PythonVirtualEnvOperator (#34359)
b23d3f964b is described below
commit b23d3f964b2699d4c7f579e22d50fabc9049d1b6
Author: starone <53...@users.noreply.github.com>
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 <ky...@bagelcode.com>
Co-authored-by: Tzu-ping Chung <ur...@gmail.com>
---
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 4dd8727519..b23d400f47 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,
@@ -555,6 +555,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 d20949c618..1d68d6543f 100644
--- a/tests/operators/test_python.py
+++ b/tests/operators/test_python.py
@@ -965,7 +965,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):