Skip to content
9 changes: 8 additions & 1 deletion airflow/operators/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def __init__(
*,
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,
Expand All @@ -555,6 +555,13 @@ def __init__(
"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:
Expand Down
2 changes: 1 addition & 1 deletion tests/operators/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def f():
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):
Expand Down