Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append/update builtins deprecations warnings instead of prepend #39089

Merged

Conversation

Taragolis
Copy link
Contributor

@Taragolis Taragolis commented Apr 17, 2024

Fix bug in test warning capture system introduced in #38905
There is redefine DeprecationWarning, PendingDeprecationWarning which are ignored by default in Python, however the problem that it use Prepend/Insert

# From CaptureWarningsPlugin
00 = {tuple: 5} ('always', None, <class 'PendingDeprecationWarning'>, None, 0)
01 = {tuple: 5} ('always', None, <class 'DeprecationWarning'>, None, 0)
# Explicit set as pytest.mark.filterwarnings
02 = {tuple: 5} ('default', None, <class 'airflow.exceptions.RemovedInAirflow3Warning'>, None, 0)
# Implicit set during pytest collect
03 = {tuple: 5} ('error', None, <class 'airflow.exceptions.RemovedInAirflow3Warning'>, None, 0)
04 = {tuple: 5} ('error', None, <class 'airflow.utils.context.AirflowContextDeprecationWarning'>, None, 0)
05 = {tuple: 5} ('error', None, <class 'airflow.exceptions.AirflowProviderDeprecationWarning'>, None, 0)
...

As result error might not happen if airflow.exceptions.RemovedInAirflow3Warning raisedduring test run because it subclass of DeprecationWarning and in this case rule 'always', None, <class 'DeprecationWarning'>, None, 0 will choose instead of 'error', None, <class 'airflow.exceptions.RemovedInAirflow3Warning'>, None, 0

After changes it update already existed and defined values in warnings.filters

# Explicit set as pytest.mark.filterwarnings
00 = {tuple: 5} ('default', None, <class 'airflow.exceptions.RemovedInAirflow3Warning'>, None, 0)
# Implicit set during pytest collect
01 = {tuple: 5} ('error', None, <class 'airflow.exceptions.RemovedInAirflow3Warning'>, None, 0)
02 = {tuple: 5} ('error', None, <class 'airflow.utils.context.AirflowContextDeprecationWarning'>, None, 0)
03 = {tuple: 5} ('error', None, <class 'airflow.exceptions.AirflowProviderDeprecationWarning'>, None, 0)
...
# Updated from CaptureWarningsPlugin
19 = {tuple: 5} ('always', None, <class 'PendingDeprecationWarning'>, None, 0)
20 = {tuple: 5} ('always', None, <class 'DeprecationWarning'>, None, 0)
...

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@Taragolis Taragolis added the full tests needed We need to run full set of tests for this PR to merge label Apr 17, 2024
@Taragolis Taragolis merged commit 5db76b9 into apache:main Apr 17, 2024
69 checks passed
@Taragolis Taragolis deleted the append-update-base-deprecations-warnings branch April 17, 2024 15:24
utkarsharma2 pushed a commit to astronomer/airflow that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants