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 80c2ccc0b43 Fix the `__init__.py` for tests (#58211)
80c2ccc0b43 is described below
commit 80c2ccc0b435dca10ba0e44b160e2eff6f8d4f5a
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue Nov 11 21:29:26 2025 +0100
Fix the `__init__.py` for tests (#58211)
The `__init__.py` for tests should have the legacy namespaces
defined in order for IDE imports to work properly. This works also
in IDEs where `tests` folders are added the path of ours (this
is done via `setup_idea.py` and `setup_vscode.py`).
There was a bug in our prek hook wher it did not have "expected"
and "namespace" __init__.py for those known test folders.
This PR fixes the prek hook and some of the recently added
folders that had wrong __init__.py added.
---
.../{tinkerpop/tests/integration => impala/tests/system}/__init__.py | 1 +
providers/apache/tinkerpop/tests/integration/__init__.py | 1 +
providers/apache/tinkerpop/tests/system/__init__.py | 1 +
providers/exasol/tests/system/__init__.py | 1 +
providers/git/tests/unit/__init__.py | 1 +
scripts/ci/prek/check_providers_subpackages_all_have_init.py | 2 +-
6 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/providers/apache/tinkerpop/tests/integration/__init__.py
b/providers/apache/impala/tests/system/__init__.py
similarity index 92%
copy from providers/apache/tinkerpop/tests/integration/__init__.py
copy to providers/apache/impala/tests/system/__init__.py
index 13a83393a91..5966d6b1d52 100644
--- a/providers/apache/tinkerpop/tests/integration/__init__.py
+++ b/providers/apache/impala/tests/system/__init__.py
@@ -14,3 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+__path__ = __import__("pkgutil").extend_path(__path__, __name__)
diff --git a/providers/apache/tinkerpop/tests/integration/__init__.py
b/providers/apache/tinkerpop/tests/integration/__init__.py
index 13a83393a91..5966d6b1d52 100644
--- a/providers/apache/tinkerpop/tests/integration/__init__.py
+++ b/providers/apache/tinkerpop/tests/integration/__init__.py
@@ -14,3 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+__path__ = __import__("pkgutil").extend_path(__path__, __name__)
diff --git a/providers/apache/tinkerpop/tests/system/__init__.py
b/providers/apache/tinkerpop/tests/system/__init__.py
index 13a83393a91..5966d6b1d52 100644
--- a/providers/apache/tinkerpop/tests/system/__init__.py
+++ b/providers/apache/tinkerpop/tests/system/__init__.py
@@ -14,3 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+__path__ = __import__("pkgutil").extend_path(__path__, __name__)
diff --git a/providers/exasol/tests/system/__init__.py
b/providers/exasol/tests/system/__init__.py
index 13a83393a91..5966d6b1d52 100644
--- a/providers/exasol/tests/system/__init__.py
+++ b/providers/exasol/tests/system/__init__.py
@@ -14,3 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+__path__ = __import__("pkgutil").extend_path(__path__, __name__)
diff --git a/providers/git/tests/unit/__init__.py
b/providers/git/tests/unit/__init__.py
index 13a83393a91..5966d6b1d52 100644
--- a/providers/git/tests/unit/__init__.py
+++ b/providers/git/tests/unit/__init__.py
@@ -14,3 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+__path__ = __import__("pkgutil").extend_path(__path__, __name__)
diff --git a/scripts/ci/prek/check_providers_subpackages_all_have_init.py
b/scripts/ci/prek/check_providers_subpackages_all_have_init.py
index 85bf55626bc..ad0445d5b0e 100755
--- a/scripts/ci/prek/check_providers_subpackages_all_have_init.py
+++ b/scripts/ci/prek/check_providers_subpackages_all_have_init.py
@@ -81,7 +81,7 @@ def _what_kind_of_test_init_py_needed(base_path: Path,
folder: Path) -> tuple[bo
global fatal_error
should_fail = True
fatal_error = True
- return False, False
+ return True, True
if depth == 2:
# For known sub-packages that can occur in several packages we need to
add __path__ extension
return True, folder.name in KNOWN_SECOND_LEVEL_PATHS