Skip to content

Add missing tests for common.compat.standard operators and triggers - #73262

Merged
shahar1 merged 2 commits into
apache:mainfrom
Zeeshan-Chaudhry:add-tests-common-compat-standard
Sep 17, 2026
Merged

shahar1 merged 2 commits into
apache:mainfrom
Zeeshan-Chaudhry:add-tests-common-compat-standard

Conversation

@Zeeshan-Chaudhry

@Zeeshan-Chaudhry Zeeshan-Chaudhry commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Neither common.compat.standard.operators nor common.compat.standard.triggers had a test module, and nothing under any providers/*/tests/ directory imported them, so a broken fallback import in either shim would only have surfaced in a downstream provider. Both were also exempted in the OVERLOOKED_TESTS allowlist in airflow-core/tests/unit/always/test_project_structure.py.

This adds the two test modules and removes those two allowlist entries, following the existing pattern in providers/common/compat/tests/unit/common/compat/test_sdk.py and the shape of the sibling PR #72487.

What the tests cover:

  • __all__ equals a hardcoded expected export list, so an accidentally removed compat export is caught. The list is deliberately hardcoded rather than derived from __all__, following the review feedback on Add tests for common compat standard utilities #72487.
  • Every export resolves to a non-None object.
  • is_async_callable detects coroutine functions through nested functools.partial wrappers. The cases asserted are only those that hold on both sides of the Airflow 3.2 fork, so the local stub and the Task SDK implementation agree on all of them.
  • On Airflow < 3.2 only, the BaseAsyncOperator stub reports is_async is True and its execute() raises RuntimeError.

How this was verified

Docker is not available on my machine, so the breeze testing providers-tests ... commands in the issue's Definition of Done could not be run. I used the local virtualenv route documented in contributing-docs/07_local_virtualenv.rst instead:

uv run --no-sync pytest providers/common/compat/tests/unit/common/compat/standard -v  # 17 passed, 2 skipped
uv run --no-sync pytest providers/common/compat/tests/unit -q                         # 238 passed, 7 skipped
uv run --no-sync pytest airflow-core/tests/unit/always/test_project_structure.py -q   # 10 passed, 1 xfailed
prek run --from-ref main --stage pre-commit
uv run --no-sync mypy --config-file pyproject.toml <the four changed files>            # no issues

Every prek hook in that stage passes except check-tests-in-the-right-folders, which exits early because breeze is not on my PATH. I ran scripts/ci/prek/check_tests_in_right_folders.py directly on the changed core test file and it passes.

The provider run also reports 2 errors in connection/test_connection.py (ModuleNotFoundError: No module named 'airflow_shared'). They are present unchanged on main at the same commit and are an artifact of my local venv, not of this change.

Red then green on the guard test: with the two allowlist entries removed but the test modules not yet added, test_providers_modules_should_have_tests fails with Detect missing tests in providers module - please add tests listing both paths. Adding the modules makes it pass.

The two version-gated stub tests are skipped locally, since the checkout is Airflow 3.4.0. I exercised that branch in a throwaway process with AIRFLOW_V_3_2_PLUS patched to False, which makes operators.py define the stub: all 19 tests in the new directory then pass, including the two stub tests. The providers compatibility matrix jobs (Airflow 2.11.1, 3.0.6, 3.1.8) are what exercise that branch for real.

Dead _IMPORT_MAP entries, now fixed here

The _IMPORT_MAP entries for BaseAsyncOperator and is_async_callable pointed at airflow.providers.common.compat.sdk, which exports neither name. They resolved only because operators.py binds both at module level on each side of the AIRFLOW_V_3_2_PLUS gate, which shadows the module __getattr__. Per review, that is fixed in this PR rather than a follow-up: both keys are removed, so every remaining key really does route through create_module_getattr, which is what the resolve-each-export test now exercises.

__all__ keeps all nine names. A literal list trips ruff F822 for the seven lazily resolved names, and there is no noqa: F822 precedent in the repo, so it stays computed in the house style of sdk.py:

__all__ = sorted([*_IMPORT_MAP, "BaseAsyncOperator", "is_async_callable"])

operators.__all__ is unchanged, both names still import directly, and the seven mapped names still resolve through the fallback chain.

Note on overlap: #72487 also adds providers/common/compat/tests/unit/common/compat/standard/__init__.py. If it merges first I will rebase and drop that file from this diff. I left its OVERLOOKED_TESTS entry for test_utils.py untouched.

closes: #72263
related: #35442


Was generative AI tooling used to co-author this PR?
  • Yes - Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

🤖 Generated with Claude Code

https://claude.ai/code/session_018eXNgswooRJJY6s1cXniYB

No test under providers/ covered these two compatibility shims directly, and
both were exempted from the project-structure guard, so a broken fallback
import would only have surfaced through a downstream provider.

Claude-Session: https://claude.ai/code/session_018eXNgswooRJJY6s1cXniYB
@boring-cyborg

boring-cyborg Bot commented Sep 17, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

BaseAsyncOperator and is_async_callable are bound by the version gate, so the
_IMPORT_MAP entries pointing at compat.sdk never resolved. Drop both keys and
keep the names in __all__, and drop the unknown-attribute tests that duplicate
test__compat_utils.py, per review.

Claude-Session: https://claude.ai/code/session_018eXNgswooRJJY6s1cXniYB
@shahar1
shahar1 merged commit 501805f into apache:main Sep 17, 2026
112 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 17, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add missing tests for common.compat.standard Operators andTtriggers

3 participants