Remove global from listener unit tests#58838
Merged
shahar1 merged 4 commits intoapache:mainfrom Nov 29, 2025
Merged
Conversation
8a661f2 to
89e0f79
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes global statements from listener unit test modules, replacing them with a cleaner pattern using functools.cache() and dataclasses. The changes improve code maintainability by eliminating global state in favor of a cached singleton pattern.
- Introduced
ListenerStatedataclass to encapsulate listener state - Replaced global variables with a cached
get_listener_state()function - Updated test files to access listener state through the new getter function
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| airflow-core/tests/unit/listeners/full_listener.py | Refactored from global variables to dataclass-based state with @cache decorator for singleton pattern |
| airflow-core/tests/unit/listeners/lifecycle_listener.py | Refactored from global variables to dataclass-based state with @cache decorator for singleton pattern |
| airflow-core/tests/unit/listeners/test_listeners.py | Updated assertions to access listener state via get_listener_state() method |
| airflow-core/tests/unit/jobs/test_base_job.py | Updated assertions to access listener state via get_listener_state() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
shahar1
approved these changes
Nov 29, 2025
RoyLee1224
pushed a commit
to RoyLee1224/airflow
that referenced
this pull request
Dec 3, 2025
* Remove global from listener unit tests * Fix dataclass * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI
pushed a commit
to jason810496/airflow
that referenced
this pull request
Dec 5, 2025
* Remove global from listener unit tests * Fix dataclass * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
itayweb
pushed a commit
to itayweb/airflow
that referenced
this pull request
Dec 6, 2025
* Remove global from listener unit tests * Fix dataclass * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Subham-KRLX
pushed a commit
to Subham-KRLX/airflow
that referenced
this pull request
Mar 4, 2026
* Remove global from listener unit tests * Fix dataclass * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Copilot review feedback Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another small increment to remove global statements for PR #58116
This just removes some global statements in unit tests, replaces with
functools.cache()globalis evil.