Repository: apache/airflow
Pull request: Added print statements for clarity in provider yaml checks
closes: #17316 
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.

Feel free to ping committers for the review!

In case of existing issue, reference it using one of the following:

closes: #17316 
related: #ISSUE

How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->

---
**^ Add meaningful description above**

Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).


Problem statement:
Docs validation function - Add meaningful errors
The following function just prints right/left error which is not very meaningful and very difficult to troubleshoot.

```python
def check_doc_files(yaml_files: Dict[str, Dict]):
    print("Checking doc files")
    current_doc_urls = []
    current_logo_urls = []
    for provider in yaml_files.values():
        if 'integrations' in provider:
            current_doc_urls.extend(
                guide
                for guides in provider['integrations']
                if 'how-to-guide' in guides
                for guide in guides['how-to-guide']
            )
            current_logo_urls.extend(
                integration['logo'] for integration in provider['integrations'] if 'logo' in integration
            )
        if 'transfers' in provider:
            current_doc_urls.extend(
                op['how-to-guide'] for op in provider['transfers'] if 'how-to-guide' in op
            )
    expected_doc_urls = {
        "/docs/" + os.path.relpath(f, start=DOCS_DIR)
        for f in glob(f"{DOCS_DIR}/apache-airflow-providers-*/operators/**/*.rst", recursive=True)
        if not f.endswith("/index.rst") and '/_partials' not in f
    }
    expected_doc_urls |= {
        "/docs/" + os.path.relpath(f, start=DOCS_DIR)
        for f in glob(f"{DOCS_DIR}/apache-airflow-providers-*/operators.rst", recursive=True)
    }
    expected_logo_urls = {
        "/" + os.path.relpath(f, start=DOCS_DIR)
        for f in glob(f"{DOCS_DIR}/integration-logos/**/*", recursive=True)
        if os.path.isfile(f)
    }
    try:
        assert_sets_equal(set(expected_doc_urls), set(current_doc_urls))
        assert_sets_equal(set(expected_logo_urls), set(current_logo_urls))
    except AssertionError as ex:
        print(ex)
        sys.exit(1)
```

Hints from issue discussion:

Commit message: Revert back change of renaming neo4j.rst

Patch to review:
diff --git a/scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py b/scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py
index 24d963bedef2b..4906b759ddbe1 100755
--- a/scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py
+++ b/scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py
@@ -119,13 +119,13 @@ def assert_sets_equal(set1, set2):
 
     lines = []
     if difference1:
-        lines.append('Items in the first set but not the second:')
+        lines.append('    -- Items in the left set but not the right:')
         for item in sorted(difference1):
-            lines.append(repr(item))
+            lines.append('       ' + repr(item))
     if difference2:
-        lines.append('Items in the second set but not the first:')
+        lines.append('    -- Items in the right set but not the left:')
         for item in sorted(difference2):
-            lines.append(repr(item))
+            lines.append('       ' + repr(item))
 
     standard_msg = '\n'.join(lines)
     raise AssertionError(standard_msg)
@@ -155,6 +155,9 @@ def parse_module_data(provider_data, resource_type, yaml_file_path):
 
 def check_completeness_of_list_of_hooks_sensors_hooks(yaml_files: Dict[str, Dict]):
     print("Checking completeness of list of {sensors, hooks, operators}")
+    print(
+        " -- {sensors, hooks, operators} - Expected modules(Left): Current Modules(Right)"
+    )
     for (yaml_file_path, provider_data), resource_type in product(
         yaml_files.items(), ["sensors", "operators", "hooks"]
     ):
@@ -193,6 +196,8 @@ def check_duplicates_in_integrations_names_of_hooks_sensors_operators(yaml_files
 def check_completeness_of_list_of_transfers(yaml_files: Dict[str, Dict]):
     print("Checking completeness of list of transfers")
     resource_type = 'transfers'
+
+    print(" -- Expected transfers modules(Left): Current transfers Modules(Right)")
     for yaml_file_path, provider_data in yaml_files.items():
         expected_modules, provider_package, resource_data = parse_module_data(
             provider_data, resource_type, yaml_file_path
@@ -309,7 +314,10 @@ def check_doc_files(yaml_files: Dict[str, Dict]):
     }
 
     try:
+        print(" -- Checking document urls: expected(left), current(right)")
         assert_sets_equal(set(expected_doc_urls), set(current_doc_urls))
+
+        print(" -- Checking logo urls: expected(left), current(right)")
         assert_sets_equal(set(expected_logo_urls), set(current_logo_urls))
     except AssertionError as ex:
         print(ex)


Code review comments:
diff_hunk: @@ -119,13 +119,13 @@ def assert_sets_equal(set1, set2):
 
     lines = []
     if difference1:
-        lines.append('Items in the first set but not the second:')
+        lines.append('    -- Items in the left set but not the right:')
         for item in sorted(difference1):
-            lines.append(repr(item))
+            lines.append('       ' + repr(item))
path: scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py
text: @user1:
```suggestion
            lines.append(f'       {item!r}')
```

diff_hunk: @@ -119,13 +119,13 @@ def assert_sets_equal(set1, set2):
 
     lines = []
     if difference1:
-        lines.append('Items in the first set but not the second:')
+        lines.append('    -- Items in the left set but not the right:')
         for item in sorted(difference1):
-            lines.append(repr(item))
+            lines.append('       ' + repr(item))
     if difference2:
-        lines.append('Items in the second set but not the first:')
+        lines.append('    -- Items in the right set but not the left:')
         for item in sorted(difference2):
-            lines.append(repr(item))
+            lines.append('       ' + repr(item))
path: scripts/ci/pre_commit/pre_commit_check_provider_yaml_files.py
text: @user1:
```suggestion
            lines.append(f'       {item!r}')
```