Skip to content

deps: Updates deprecation warning to FutureWarning re: 3.7 and 3.8 #338

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

Merged
merged 4 commits into from
Apr 24, 2025

Conversation

chalmerlowe
Copy link
Collaborator

Revises the Python 3.7/3.8 PendingDeprecationWarning to a FutureWarning and isolates the logic into a function for easier testing.

This is in support of a larger and more complicated PR coming that will drop support for 3.7 and 3.8:

#337

@chalmerlowe chalmerlowe requested review from a team as code owners April 24, 2025 16:12
@chalmerlowe chalmerlowe requested a review from suzmue April 24, 2025 16:12
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-db-dtypes-pandas API. labels Apr 24, 2025
@chalmerlowe
Copy link
Collaborator Author

@tswast

Separate PR discussed in PR #337 to get the FutureWarning out.

I looked at Unittest 3.9 and it looked like everything ran and completed, but it says cancelled.

Unittest 3.8 fails cause it gets FutureWarnings and that generates an error for pytest/nox.

Copy link
Collaborator

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment on lines +43 to +45
with mock.patch(MOCK_EXTRACT_VERSION, return_value=mock_version_tuple), mock.patch(
MOCK_WARN
) as mock_warn_call:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if you've tried pytest.warns context manager rather than mocking out warnings.warn? https://docs.pytest.org/en/stable/how-to/capture-warnings.html#warns

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used the pytest.warns context manager in several places. During troubleshooting this, we tried many, many approaches and all of them failed so we swapped out a ton of things to try and find a solution that ended up working.

  • dependencies and import timing will be the death of me.

(3, 12, 0),
],
)
def test_check_python_version_does_not_warn_on_supported(mock_version_tuple):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a pytest.skip for older Pythons if the extra warning is causing trouble here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a pytest issue, per se. i.e. it is not the test that triggers the problem and thus we can't mark a specific test as .skipif(sys.version <= (3, 8)).

When we run a file such as test_arrow, line 24 is import db-dtypes and the process of importing triggers the warning if we run under Py 3.7 and 3.8, which we definitely do in this PR cause another PR removes dependencies on Py37 and Py38.

So this is kind of a catch-22.

@chalmerlowe chalmerlowe merged commit 158243b into main Apr 24, 2025
24 checks passed
@chalmerlowe chalmerlowe deleted the refactor-isolate-runtime-check branch April 24, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-db-dtypes-pandas API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants