This is an automated email from the ASF dual-hosted git repository.

potiuk 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 094e50eb43 Replace "absolute()" with "resolve()" in pathlib objects 
(#23675)
094e50eb43 is described below

commit 094e50eb439e1c22e14ee78f375b7e00c71e9269
Author: Jarek Potiuk <[email protected]>
AuthorDate: Thu May 12 19:30:39 2022 +0200

    Replace "absolute()" with "resolve()" in pathlib objects (#23675)
    
    TIL that absolute() is an undocumented in Pathlib and that we
    should use resolve() instead.
    
    So this is it.
---
 airflow/providers/amazon/aws/hooks/batch_waiters.py               | 2 +-
 dev/breeze/tests/test_cache.py                                    | 2 +-
 dev/breeze/tests/test_find_airflow_directory.py                   | 2 +-
 scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py               | 2 +-
 scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py | 4 ++--
 scripts/ci/pre_commit/pre_commit_check_pre_commit_hooks.py        | 4 ++--
 scripts/ci/pre_commit/pre_commit_flake8.py                        | 4 ++--
 scripts/ci/pre_commit/pre_commit_inline_scripts_in_docker.py      | 2 +-
 scripts/ci/pre_commit/pre_commit_insert_extras.py                 | 4 ++--
 scripts/ci/pre_commit/pre_commit_migration_reference.py           | 4 ++--
 scripts/ci/pre_commit/pre_commit_mypy.py                          | 4 ++--
 scripts/ci/pre_commit/pre_commit_ui_lint.py                       | 4 ++--
 scripts/ci/pre_commit/pre_commit_update_breeze_config_hash.py     | 2 +-
 scripts/ci/pre_commit/pre_commit_www_lint.py                      | 4 ++--
 scripts/in_container/run_migration_reference.py                   | 2 +-
 scripts/in_container/verify_providers.py                          | 4 ++--
 tests/dag_processing/test_manager.py                              | 2 +-
 tests/executors/test_kubernetes_executor.py                       | 4 ++--
 tests/utils/test_db_cleanup.py                                    | 2 +-
 19 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/airflow/providers/amazon/aws/hooks/batch_waiters.py 
b/airflow/providers/amazon/aws/hooks/batch_waiters.py
index 29c10e4f46..59ba0e431f 100644
--- a/airflow/providers/amazon/aws/hooks/batch_waiters.py
+++ b/airflow/providers/amazon/aws/hooks/batch_waiters.py
@@ -120,7 +120,7 @@ class BatchWaitersHook(BatchClientHook):
         :rtype: Dict
         """
         if self._default_config is None:
-            config_path = 
Path(__file__).with_name("batch_waiters.json").absolute()
+            config_path = 
Path(__file__).with_name("batch_waiters.json").resolve()
             with open(config_path) as config_file:
                 self._default_config = json.load(config_file)
         return deepcopy(self._default_config)  # avoid accidental mutation
diff --git a/dev/breeze/tests/test_cache.py b/dev/breeze/tests/test_cache.py
index 7bc53ae560..1a1e388f01 100644
--- a/dev/breeze/tests/test_cache.py
+++ b/dev/breeze/tests/test_cache.py
@@ -27,7 +27,7 @@ from airflow_breeze.utils.cache import (
     read_from_cache_file,
 )
 
-AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 
 
 @pytest.mark.parametrize(
diff --git a/dev/breeze/tests/test_find_airflow_directory.py 
b/dev/breeze/tests/test_find_airflow_directory.py
index f0280142c3..99da5ce04e 100644
--- a/dev/breeze/tests/test_find_airflow_directory.py
+++ b/dev/breeze/tests/test_find_airflow_directory.py
@@ -21,7 +21,7 @@ from unittest import mock
 
 from airflow_breeze.utils.path_utils import 
find_airflow_sources_root_to_operate_on
 
-ACTUAL_AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+ACTUAL_AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 ROOT_PATH = Path(Path(__file__).root)
 
 
diff --git a/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py 
b/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py
index abda3fd834..c01c6bfbf6 100755
--- a/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py
+++ b/scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py
@@ -23,7 +23,7 @@ from subprocess import check_call, check_output, run
 
 from rich.console import Console
 
-AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].resolve()
 BREEZE_IMAGES_DIR = AIRFLOW_SOURCES_DIR / "images" / "breeze"
 BREEZE_INSTALL_DIR = AIRFLOW_SOURCES_DIR / "dev" / "breeze"
 BREEZE_SOURCES_DIR = BREEZE_INSTALL_DIR / "src"
diff --git a/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py 
b/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py
index 2658b09ced..f0bf1a05c9 100755
--- a/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py
+++ b/scripts/ci/pre_commit/pre_commit_check_order_dockerfile_extras.py
@@ -29,9 +29,9 @@ from rich import print
 
 errors = []
 
-MY_DIR_PATH = Path(__file__).parent.absolute()
+MY_DIR_PATH = Path(__file__).parent.resolve()
 
-SOURCE_DIR_PATH = MY_DIR_PATH.parents[2].absolute()
+SOURCE_DIR_PATH = MY_DIR_PATH.parents[2].resolve()
 BUILD_ARGS_REF_PATH = SOURCE_DIR_PATH / "docs" / "docker-stack" / 
"build-arg-ref.rst"
 GLOBAL_CONSTANTS_PATH = SOURCE_DIR_PATH / "dev" / "breeze" / "src" / 
"airflow_breeze" / "global_constants.py"
 
diff --git a/scripts/ci/pre_commit/pre_commit_check_pre_commit_hooks.py 
b/scripts/ci/pre_commit/pre_commit_check_pre_commit_hooks.py
index d007ab0998..8c43addd20 100755
--- a/scripts/ci/pre_commit/pre_commit_check_pre_commit_hooks.py
+++ b/scripts/ci/pre_commit/pre_commit_check_pre_commit_hooks.py
@@ -25,7 +25,7 @@ import argparse
 import sys
 from pathlib import Path
 
-sys.path.insert(0, str(Path(__file__).parent.absolute()))  # make sure 
common_precommit_utils is imported
+sys.path.insert(0, str(Path(__file__).parent.resolve()))  # make sure 
common_precommit_utils is imported
 
 from collections import defaultdict  # noqa: E402
 from functools import lru_cache  # noqa: E402
@@ -38,7 +38,7 @@ from tabulate import tabulate  # noqa: E402
 
 console = Console(width=400, color_system="standard")
 
-AIRFLOW_SOURCES_PATH = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES_PATH = Path(__file__).parents[3].resolve()
 AIRFLOW_BREEZE_SOURCES_PATH = AIRFLOW_SOURCES_PATH / "dev" / "breeze"
 PRE_COMMIT_IDS_PATH = AIRFLOW_BREEZE_SOURCES_PATH / "src" / "airflow_breeze" / 
"pre_commit_ids.py"
 PRE_COMMIT_YAML_FILE = AIRFLOW_SOURCES_PATH / ".pre-commit-config.yaml"
diff --git a/scripts/ci/pre_commit/pre_commit_flake8.py 
b/scripts/ci/pre_commit/pre_commit_flake8.py
index 19841b3347..6b46333403 100755
--- a/scripts/ci/pre_commit/pre_commit_flake8.py
+++ b/scripts/ci/pre_commit/pre_commit_flake8.py
@@ -28,11 +28,11 @@ if __name__ not in ("__main__", "__mp_main__"):
         f"To run this script, run the ./{__file__} command"
     )
 
-AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', "apache/airflow")
 
 if __name__ == '__main__':
-    sys.path.insert(0, str(Path(__file__).parents[3].absolute() / "dev" / 
"breeze" / "src"))
+    sys.path.insert(0, str(Path(__file__).parents[3].resolve() / "dev" / 
"breeze" / "src"))
     from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
 
     AIRFLOW_CI_IMAGE = 
f"ghcr.io/{GITHUB_REPOSITORY}/{AIRFLOW_BRANCH}/ci/python3.7"
diff --git a/scripts/ci/pre_commit/pre_commit_inline_scripts_in_docker.py 
b/scripts/ci/pre_commit/pre_commit_inline_scripts_in_docker.py
index 2d78815097..a528ba46ae 100755
--- a/scripts/ci/pre_commit/pre_commit_inline_scripts_in_docker.py
+++ b/scripts/ci/pre_commit/pre_commit_inline_scripts_in_docker.py
@@ -19,7 +19,7 @@ from os import listdir
 from pathlib import Path
 from typing import List
 
-AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].resolve()
 
 
 def insert_content(file_path: Path, content: List[str], header: str, footer: 
str, file_name: str):
diff --git a/scripts/ci/pre_commit/pre_commit_insert_extras.py 
b/scripts/ci/pre_commit/pre_commit_insert_extras.py
index 79c0a6e989..1c79190ea6 100755
--- a/scripts/ci/pre_commit/pre_commit_insert_extras.py
+++ b/scripts/ci/pre_commit/pre_commit_insert_extras.py
@@ -19,9 +19,9 @@ import sys
 from pathlib import Path
 from textwrap import wrap
 
-AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES_DIR = Path(__file__).parents[3].resolve()
 
-sys.path.insert(0, str(Path(__file__).parent.absolute()))  # make sure 
common_precommit_utils is imported
+sys.path.insert(0, str(Path(__file__).parent.resolve()))  # make sure 
common_precommit_utils is imported
 sys.path.insert(0, str(AIRFLOW_SOURCES_DIR))  # make sure setup is imported 
from Airflow
 # flake8: noqa: F401
 
diff --git a/scripts/ci/pre_commit/pre_commit_migration_reference.py 
b/scripts/ci/pre_commit/pre_commit_migration_reference.py
index 6e1fc15c19..e72a7a3326 100755
--- a/scripts/ci/pre_commit/pre_commit_migration_reference.py
+++ b/scripts/ci/pre_commit/pre_commit_migration_reference.py
@@ -28,11 +28,11 @@ if __name__ not in ("__main__", "__mp_main__"):
         f"To run this script, run the ./{__file__} command"
     )
 
-AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', "apache/airflow")
 
 if __name__ == '__main__':
-    sys.path.insert(0, str(Path(__file__).parents[3].absolute() / "dev" / 
"breeze" / "src"))
+    sys.path.insert(0, str(Path(__file__).parents[3].resolve() / "dev" / 
"breeze" / "src"))
     from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
 
     AIRFLOW_CI_IMAGE = 
f"ghcr.io/{GITHUB_REPOSITORY}/{AIRFLOW_BRANCH}/ci/python3.7"
diff --git a/scripts/ci/pre_commit/pre_commit_mypy.py 
b/scripts/ci/pre_commit/pre_commit_mypy.py
index 0c70b96d52..1b78be3c9e 100755
--- a/scripts/ci/pre_commit/pre_commit_mypy.py
+++ b/scripts/ci/pre_commit/pre_commit_mypy.py
@@ -29,11 +29,11 @@ if __name__ not in ("__main__", "__mp_main__"):
     )
 
 
-AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', "apache/airflow")
 
 if __name__ == '__main__':
-    sys.path.insert(0, str(Path(__file__).parents[3].absolute() / "dev" / 
"breeze" / "src"))
+    sys.path.insert(0, str(Path(__file__).parents[3].resolve() / "dev" / 
"breeze" / "src"))
     from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
 
     AIRFLOW_CI_IMAGE = 
f"ghcr.io/{GITHUB_REPOSITORY}/{AIRFLOW_BRANCH}/ci/python3.7"
diff --git a/scripts/ci/pre_commit/pre_commit_ui_lint.py 
b/scripts/ci/pre_commit/pre_commit_ui_lint.py
index 45360faa85..93a5c3bf72 100755
--- a/scripts/ci/pre_commit/pre_commit_ui_lint.py
+++ b/scripts/ci/pre_commit/pre_commit_ui_lint.py
@@ -28,12 +28,12 @@ if __name__ not in ("__main__", "__mp_main__"):
         f"To run this script, run the ./{__file__} command"
     )
 
-AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', "apache/airflow")
 AIRFLOW_CI_IMAGE = f"ghcr.io/{GITHUB_REPOSITORY}/main/ci/python3.7"
 
 if __name__ == '__main__':
-    sys.path.insert(0, str(Path(__file__).parents[3].absolute() / "dev" / 
"breeze" / "src"))
+    sys.path.insert(0, str(Path(__file__).parents[3].resolve() / "dev" / 
"breeze" / "src"))
     from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
 
     AIRFLOW_CI_IMAGE = 
f"ghcr.io/{GITHUB_REPOSITORY}/{AIRFLOW_BRANCH}/ci/python3.7"
diff --git a/scripts/ci/pre_commit/pre_commit_update_breeze_config_hash.py 
b/scripts/ci/pre_commit/pre_commit_update_breeze_config_hash.py
index 3a480b6fcc..455f5da49a 100755
--- a/scripts/ci/pre_commit/pre_commit_update_breeze_config_hash.py
+++ b/scripts/ci/pre_commit/pre_commit_update_breeze_config_hash.py
@@ -24,7 +24,7 @@ if __name__ not in ("__main__", "__mp_main__"):
         f"To execute this script, run ./{__file__} [FILE] ..."
     )
 
-AIRFLOW_SOURCES_ROOT = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES_ROOT = Path(__file__).parents[3].resolve()
 BREEZE_SOURCES_ROOT = AIRFLOW_SOURCES_ROOT / "dev" / "breeze"
 
 
diff --git a/scripts/ci/pre_commit/pre_commit_www_lint.py 
b/scripts/ci/pre_commit/pre_commit_www_lint.py
index 5e0d1f83ab..c2807d4082 100755
--- a/scripts/ci/pre_commit/pre_commit_www_lint.py
+++ b/scripts/ci/pre_commit/pre_commit_www_lint.py
@@ -28,12 +28,12 @@ if __name__ not in ("__main__", "__mp_main__"):
         f"To run this script, run the ./{__file__} command"
     )
 
-AIRFLOW_SOURCES = Path(__file__).parents[3].absolute()
+AIRFLOW_SOURCES = Path(__file__).parents[3].resolve()
 GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', "apache/airflow")
 AIRFLOW_CI_IMAGE = f"ghcr.io/{GITHUB_REPOSITORY}/main/ci/python3.7"
 
 if __name__ == '__main__':
-    sys.path.insert(0, str(Path(__file__).parents[3].absolute() / "dev" / 
"breeze" / "src"))
+    sys.path.insert(0, str(Path(__file__).parents[3].resolve() / "dev" / 
"breeze" / "src"))
     from airflow_breeze.branch_defaults import AIRFLOW_BRANCH
 
     AIRFLOW_CI_IMAGE = 
f"ghcr.io/{GITHUB_REPOSITORY}/{AIRFLOW_BRANCH}/ci/python3.7"
diff --git a/scripts/in_container/run_migration_reference.py 
b/scripts/in_container/run_migration_reference.py
index 3af7ad8bf7..79585abb04 100755
--- a/scripts/in_container/run_migration_reference.py
+++ b/scripts/in_container/run_migration_reference.py
@@ -35,7 +35,7 @@ if TYPE_CHECKING:
     from alembic.script import Script
 
 airflow_version = re.match(r'(\d+\.\d+\.\d+).*', _airflow_version).group(1)  # 
type: ignore
-project_root = Path(__file__).parents[2].absolute()
+project_root = Path(__file__).parents[2].resolve()
 
 
 def replace_text_between(file: Path, start: str, end: str, replacement_text: 
str):
diff --git a/scripts/in_container/verify_providers.py 
b/scripts/in_container/verify_providers.py
index 3a1765473a..532b0f89fe 100755
--- a/scripts/in_container/verify_providers.py
+++ b/scripts/in_container/verify_providers.py
@@ -33,7 +33,7 @@ from rich.console import Console
 
 console = Console(width=400, color_system="standard")
 
-AIRFLOW_SOURCES_ROOT = Path(__file__).parents[2].absolute()
+AIRFLOW_SOURCES_ROOT = Path(__file__).parents[2].resolve()
 PROVIDERS_PATH = AIRFLOW_SOURCES_ROOT / "airflow" / "providers"
 
 
@@ -835,7 +835,7 @@ def add_all_namespaced_packages(
     :param provider_path:
     :param provider_prefix:
     """
-    main_path = Path(provider_path).absolute()
+    main_path = Path(provider_path).resolve()
     for candidate_path in main_path.rglob("*"):
         if candidate_path.name == "__pycache__":
             continue
diff --git a/tests/dag_processing/test_manager.py 
b/tests/dag_processing/test_manager.py
index 1e5ebbaaf3..6a65116d51 100644
--- a/tests/dag_processing/test_manager.py
+++ b/tests/dag_processing/test_manager.py
@@ -57,7 +57,7 @@ from tests.models import TEST_DAGS_FOLDER
 from tests.test_utils.config import conf_vars
 from tests.test_utils.db import clear_db_callbacks, clear_db_dags, 
clear_db_runs, clear_db_serialized_dags
 
-TEST_DAG_FOLDER = pathlib.Path(__file__).parents[1].absolute() / 'dags'
+TEST_DAG_FOLDER = pathlib.Path(__file__).parents[1].resolve() / 'dags'
 
 DEFAULT_DATE = timezone.datetime(2016, 1, 1)
 
diff --git a/tests/executors/test_kubernetes_executor.py 
b/tests/executors/test_kubernetes_executor.py
index a332a2fd6a..954f4f0600 100644
--- a/tests/executors/test_kubernetes_executor.py
+++ b/tests/executors/test_kubernetes_executor.py
@@ -313,9 +313,9 @@ class TestKubernetesExecutor:
     
@mock.patch('airflow.executors.kubernetes_executor.AirflowKubernetesScheduler.run_pod_async')
     @mock.patch('airflow.executors.kubernetes_executor.get_kube_client')
     def test_pod_template_file_override_in_executor_config(self, 
mock_get_kube_client, mock_run_pod_async):
-        current_folder = pathlib.Path(__file__).parent.absolute()
+        current_folder = pathlib.Path(__file__).parent.resolve()
         template_file = str(
-            (current_folder / "kubernetes_executor_template_files" / 
"basic_template.yaml").absolute()
+            (current_folder / "kubernetes_executor_template_files" / 
"basic_template.yaml").resolve()
         )
 
         mock_kube_client = mock.patch('kubernetes.client.CoreV1Api', 
autospec=True)
diff --git a/tests/utils/test_db_cleanup.py b/tests/utils/test_db_cleanup.py
index 39175001a1..8d227df6e5 100644
--- a/tests/utils/test_db_cleanup.py
+++ b/tests/utils/test_db_cleanup.py
@@ -208,7 +208,7 @@ class TestDBCleanup:
         """
         import pkgutil
 
-        proj_root = Path(__file__).parents[2].absolute()
+        proj_root = Path(__file__).parents[2].resolve()
         mods = list(
             f"airflow.models.{name}"
             for _, name, _ in pkgutil.iter_modules([str(proj_root / 
'airflow/models')])

Reply via email to