diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07994c142b..1193db6c48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,7 +70,7 @@ repos: - id: rst-backticks - id: python-check-mock-methods - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 + rev: v1.5.6 hooks: - id: remove-crlf - id: remove-tabs @@ -83,13 +83,13 @@ repos: - --py310-plus - --keep-runtime-typing - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.11 + rev: v0.14.13 hooks: - id: ruff args: - --fix - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.1.0 hooks: - id: black args: ["--config", "./pyproject.toml"] diff --git a/cosmos/__init__.py b/cosmos/__init__.py index 4b73a23d72..7503750955 100644 --- a/cosmos/__init__.py +++ b/cosmos/__init__.py @@ -5,6 +5,7 @@ Contains dags, task groups, and operators. """ + from __future__ import annotations from cosmos import settings diff --git a/cosmos/converter.py b/cosmos/converter.py index a18128578a..d5bb407cee 100644 --- a/cosmos/converter.py +++ b/cosmos/converter.py @@ -284,10 +284,8 @@ def __init__( validate_changed_config_paths(execution_config, project_config, render_config) if execution_config.execution_mode != ExecutionMode.VIRTUALENV and execution_config.virtualenv_dir is not None: - logger.warning( - "`ExecutionConfig.virtualenv_dir` is only supported when \ - ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV." - ) + logger.warning("`ExecutionConfig.virtualenv_dir` is only supported when \ + ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV.") cache_dir = None cache_identifier = None diff --git a/cosmos/dbt/graph.py b/cosmos/dbt/graph.py index 7df33d9338..fd291508a0 100644 --- a/cosmos/dbt/graph.py +++ b/cosmos/dbt/graph.py @@ -778,7 +778,7 @@ def load_via_dbt_ls_without_cache(self) -> None: ) as profile_values, environ(self.env_vars), ): - (profile_path, env_vars) = profile_values + profile_path, env_vars = profile_values env = os.environ.copy() env.update(env_vars) diff --git a/cosmos/operators/local.py b/cosmos/operators/local.py index 2b37d6d821..e868c04fd6 100644 --- a/cosmos/operators/local.py +++ b/cosmos/operators/local.py @@ -663,7 +663,7 @@ def run_command( # noqa: C901 self._handle_partial_parse(tmp_dir_path) with self.profile_config.ensure_profile() as profile_values: - (profile_path, env_vars) = profile_values + profile_path, env_vars = profile_values env.update(env_vars) logger.debug("Using environment variables keys: %s", env.keys()) @@ -752,26 +752,22 @@ def _create_asset_uri(openlineage_event: openlineage.client.generated.base.Outpu if settings.use_dataset_airflow3_uri_standard: dataset_uri = airflow_3_uri else: - logger.warning( - f""" + logger.warning(f""" Airflow 3.0.0 Asset (Dataset) URIs validation rules changed and OpenLineage URIs (standard used by Cosmos) will no longer be valid. Therefore, if using Cosmos with Airflow 3, the Airflow Dataset URIs will be changed to <{airflow_3_uri}>. Previously, with Airflow 2.x, the URI was <{airflow_2_uri}>. If you want to use the Airflow 3 URI standard while still using Airflow 2, please, set: export AIRFLOW__COSMOS__USE_DATASET_AIRFLOW3_URI_STANDARD=1 Remember to update any DAGs that are scheduled using this dataset. - """ - ) + """) dataset_uri = airflow_2_uri else: - logger.warning( - f""" + logger.warning(f""" Airflow 3.0.0 Asset (Dataset) URIs validation rules changed and OpenLineage URIs (standard used by Cosmos) are no longer accepted. Therefore, if using Cosmos with Airflow 3, the Airflow Asset (Dataset) URI is now <{airflow_3_uri}>. Before, with Airflow 2.x, the URI used to be <{airflow_2_uri}>. Please, change any DAGs that were scheduled using the old standard to the new one. - """ - ) + """) dataset_uri = airflow_3_uri return dataset_uri diff --git a/tests/test_converter.py b/tests/test_converter.py index 89dee14e05..4bc319722a 100644 --- a/tests/test_converter.py +++ b/tests/test_converter.py @@ -599,11 +599,8 @@ def test_converter_raises_warning(mock_load_dbt_graph, execution_mode, virtualen operator_args=operator_args, ) - assert ( - "`ExecutionConfig.virtualenv_dir` is only supported when \ - ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV." - in caplog.text - ) + assert "`ExecutionConfig.virtualenv_dir` is only supported when \ + ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV." in caplog.text @pytest.mark.parametrize( diff --git a/tests/test_settings.py b/tests/test_settings.py index 5bb0ad37d5..1b8f79fa33 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -14,30 +14,26 @@ def test_enable_cache_env_var(): def test_enable_memory_optimised_imports_true(monkeypatch): - script = textwrap.dedent( - """ + script = textwrap.dedent(""" import os os.environ["AIRFLOW__COSMOS__ENABLE_MEMORY_OPTIMISED_IMPORTS"] = "True" import cosmos assert cosmos.settings.enable_memory_optimised_imports is True assert not hasattr(cosmos, "DbtDag") - """ - ) + """) result = subprocess.run(["python", "-c", script], capture_output=True, text=True) assert result.returncode == 0, result.stderr def test_enable_memory_optimised_imports_false(monkeypatch): - script = textwrap.dedent( - """ + script = textwrap.dedent(""" import os os.environ["AIRFLOW__COSMOS__ENABLE_MEMORY_OPTIMISED_IMPORTS"] = "False" import cosmos assert cosmos.settings.enable_memory_optimised_imports is False assert hasattr(cosmos, "DbtDag") - """ - ) + """) result = subprocess.run(["python", "-c", script], capture_output=True, text=True) assert result.returncode == 0, result.stderr