Problem
scripts/validate_integration.py currently treats __init__.py as required for "package-style" integrations and optional for "modular" integrations (those with an actions/ directory):
# validate_integration.py:119–124
# __init__.py is optional for modular integrations (those with an actions/...
if not (self.path / '__init__.py').exists() and not has_actions_dir:
self.add_warning(
"Missing __init__.py (required for package-style integrations, "
"optional for modular integrations with actions/)"
)
This rule misses a third legitimate case: single-file integrations whose folder name collides with a third-party PyPI package the integration imports.
Concrete example
The supadata integration imports the upstream SDK:
# supadata_transcribe.py
from supadata import Supadata, SupadataError
…and lives in a folder also called supadata/. With supadata/__init__.py present and the repo root on sys.path (the pytest default), Python's import resolution finds the empty integration package first and never reaches the real PyPI supadata library — every test fails with ImportError.
Two ways out:
- Keep
__init__.py and work around the shadow with site.getsitepackages() + importlib.util.spec_from_file_location shims duplicated across every test file in the integration. That was the state of the PR before autohive-ai/autohive-integrations#280.
- Drop
__init__.py and use clean imports. That's what we did, at the cost of a now-incorrect validator warning for supadata.
We chose (2) because it's structurally cleaner, but it leaves the validator emitting a warning that is technically wrong: supadata should not have an __init__.py — adding one would actively break it.
Proposal
Extend the "optional" exception to cover this case. Concretely, in _check_init_py / the missing-init check:
- If
<integration>/__init__.py is missing and at least one Python source file in the integration imports <integration> (e.g. from <integration> import … or import <integration>), treat it as a deliberate, optional omission and skip the warning.
That detection is a small AST walk over the integration's top-level .py files, looking for Import / ImportFrom nodes whose root module name matches the folder name.
Alternative (simpler but coarser): also exempt integrations whose requirements.txt lists a PyPI package whose distribution name matches the folder name. This avoids parsing imports at all and is good enough in practice — supadata requires supadata, and that's the signal.
Acceptance criteria
- Running
validate_integration.py supadata on the autohive-integrations master tree (after PR #280 merges) produces 0 warnings.
- Existing single-file integrations that should have an
__init__.py (the other 19 SDK 2.0 ones) still get the warning if it's removed.
- A unit test in
tests/ that covers the new exception (folder name == one of the requirements.txt entries → no warning when __init__.py missing).
Context
Problem
scripts/validate_integration.pycurrently treats__init__.pyas required for "package-style" integrations and optional for "modular" integrations (those with anactions/directory):This rule misses a third legitimate case: single-file integrations whose folder name collides with a third-party PyPI package the integration imports.
Concrete example
The
supadataintegration imports the upstream SDK:…and lives in a folder also called
supadata/. Withsupadata/__init__.pypresent and the repo root onsys.path(the pytest default), Python's import resolution finds the empty integration package first and never reaches the real PyPIsupadatalibrary — every test fails withImportError.Two ways out:
__init__.pyand work around the shadow withsite.getsitepackages()+importlib.util.spec_from_file_locationshims duplicated across every test file in the integration. That was the state of the PR before autohive-ai/autohive-integrations#280.__init__.pyand use clean imports. That's what we did, at the cost of a now-incorrect validator warning forsupadata.We chose (2) because it's structurally cleaner, but it leaves the validator emitting a warning that is technically wrong:
supadatashould not have an__init__.py— adding one would actively break it.Proposal
Extend the "optional" exception to cover this case. Concretely, in
_check_init_py/ the missing-init check:<integration>/__init__.pyis missing and at least one Python source file in the integration imports<integration>(e.g.from <integration> import …orimport <integration>), treat it as a deliberate, optional omission and skip the warning.That detection is a small AST walk over the integration's top-level
.pyfiles, looking forImport/ImportFromnodes whose root module name matches the folder name.Alternative (simpler but coarser): also exempt integrations whose
requirements.txtlists a PyPI package whose distribution name matches the folder name. This avoids parsing imports at all and is good enough in practice —supadatarequiressupadata, and that's the signal.Acceptance criteria
validate_integration.py supadataon the autohive-integrations master tree (after PR #280 merges) produces 0 warnings.__init__.py(the other 19 SDK 2.0 ones) still get the warning if it's removed.tests/that covers the new exception (folder name == one of the requirements.txt entries → no warning when__init__.pymissing).Context