From e9950d7bf2c2a02dacaee9af28a2a725de085d94 Mon Sep 17 00:00:00 2001 From: Tatiana Al-Chueyr Date: Mon, 4 Dec 2023 12:42:12 +0000 Subject: [PATCH 1/2] Fix functools cache test issue (#742) Fix exceptions raised for some versions of Python (e.g. 2.4) after prematurely merging #732, leading to the main branch becoming red ``` ../../../.local/share/hatch/env/virtual/astronomer-cosmos/Za_bFbg4/tests.py3.8-2.5/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:186: in exec_module exec(co, module.__dict__) tests/test_example_dags_no_connections.py:4: in from functools import cache E ImportError: cannot import name 'cache' from 'functools' ``` --- tests/test_example_dags.py | 7 ++++++- tests/test_example_dags_no_connections.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_example_dags.py b/tests/test_example_dags.py index 41b967e92..11655a31d 100644 --- a/tests/test_example_dags.py +++ b/tests/test_example_dags.py @@ -1,7 +1,12 @@ from __future__ import annotations from pathlib import Path -from functools import cache + +try: + from functools import cache +except ImportError: + from functools import lru_cache as cache + import airflow import pytest diff --git a/tests/test_example_dags_no_connections.py b/tests/test_example_dags_no_connections.py index 97f39bf99..5356c4ea6 100644 --- a/tests/test_example_dags_no_connections.py +++ b/tests/test_example_dags_no_connections.py @@ -1,7 +1,11 @@ from __future__ import annotations from pathlib import Path -from functools import cache + +try: + from functools import cache +except ImportError: + from functools import lru_cache as cache import airflow import pytest From abeb15c4c8b346fe9e1ab52e133f66cb6191348a Mon Sep 17 00:00:00 2001 From: Mark Olliver Date: Mon, 4 Dec 2023 13:16:38 +0000 Subject: [PATCH 2/2] Optional pydantic (#736) Converts pydantic to being optional, as it is required for Airflow 2.6 but not others. Closes #725 Closes #654 --- pyproject.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df304c3b5..fe399daee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,10 +34,8 @@ classifiers = [ "Programming Language :: Python :: 3.10", ] dependencies = [ - # Airflow & Pydantic issue: https://github.com/apache/airflow/issues/32311 "aenum", "attrs", - "pydantic>=1.10.0,<2.0.0", "apache-airflow>=2.3.0", "importlib-metadata; python_version < '3.8'", "Jinja2>=3.0.0", @@ -119,6 +117,9 @@ docker = [ kubernetes = [ "apache-airflow-providers-cncf-kubernetes>=5.1.1", ] +pydantic = [ + "pydantic>=1.10.0,<2.0.0", +] [project.entry-points.cosmos] @@ -164,6 +165,7 @@ matrix.airflow.dependencies = [ { value = "apache-airflow==2.4", if = ["2.4"] }, { value = "apache-airflow==2.5", if = ["2.5"] }, { value = "apache-airflow==2.6", if = ["2.6"] }, + { value = "pydantic>=1.10.0,<2.0.0", if = ["2.6"]}, { value = "apache-airflow==2.7", if = ["2.7"] }, ]