Skip to content

deps!: Drop support for Python 3.7 and 3.8 (AI Experiment) #337

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

chalmerlowe
Copy link
Collaborator

This branch is generated automagically via AI as an experiment.
Requires a comprehensive human review and comment.
Do not merge until approved by an authorized reviewer.

Removes support for Python 3.7 and 3.8, establishing Python 3.9 as the new minimum supported version.

This change involves:

  • Updating python_requires and classifiers in setup.py.
  • Modifying Python versions in noxfile.py (default, unit tests, system tests) and ensuring constraint file logic remains correct.
  • Updating the GitHub Actions workflow (unittest.yml) matrix, runner, and coverage job version.
  • Deleting constraint files for Python 3.7 and 3.8 (testing/constraints-3.7.txt, testing/constraints-3.8.txt).
  • Removing Kokoro sample configuration directories (.kokoro/samples/python3.7/, .kokoro/samples/python3.8/).
  • Updating supported version mentions in README.rst.
  • Removing 3.7 and 3.8 from the ALL_VERSIONS list in samples/snippets/noxfile.py.

Removes support for Python 3.7 and 3.8, establishing Python 3.9 as the new minimum supported version.

This change involves:
- Updating `python_requires` and classifiers in `setup.py`.
- Modifying Python versions in `noxfile.py` (default, unit tests, system tests) and ensuring constraint file logic remains correct.
- Updating the GitHub Actions workflow (`unittest.yml`) matrix, runner, and coverage job version.
- Deleting constraint files for Python 3.7 and 3.8 (`testing/constraints-3.7.txt`, `testing/constraints-3.8.txt`).
- Removing Kokoro sample configuration directories (`.kokoro/samples/python3.7/`, `.kokoro/samples/python3.8/`).
- Updating supported version mentions in `README.rst`.
- Removing 3.7 and 3.8 from the `ALL_VERSIONS` list in `samples/snippets/noxfile.py`.
@chalmerlowe chalmerlowe added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 17, 2025
@chalmerlowe chalmerlowe self-assigned this Apr 17, 2025
@chalmerlowe chalmerlowe requested review from a team as code owners April 17, 2025 19:49
@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. samples Issues that are directly related to samples. labels Apr 17, 2025
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 18, 2025
@Linchin
Copy link
Contributor

Linchin commented Apr 23, 2025

Just a suggestion, maybe use deps!: so this commit shows up in release notes? (I'm not 100% sure if a breaking change "chore" will appear in the release, though)

@chalmerlowe
Copy link
Collaborator Author

Just a suggestion, maybe use deps!: so this commit shows up in release notes? (I'm not 100% sure if a breaking change "chore" will appear in the release, though)

Conventional Commit points at this page as reference for prefixes:

'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test'

If Google also uses deps, then sure.

@Linchin
Copy link
Contributor

Linchin commented Apr 23, 2025

Wow, I suggested it because we used it in the commit for python-bigquery. Apparently it's not part of convetional commits, but it worked.

Edit:
It seems conventional commits doesn't enforce a whitelist of commit types

@chalmerlowe chalmerlowe changed the title chore!: Drop support for Python 3.7 and 3.8 (AI Experiment) deps!: Drop support for Python 3.7 and 3.8 (AI Experiment) Apr 23, 2025
@chalmerlowe
Copy link
Collaborator Author

Done.

Comment on lines 340 to 342
# Inside db_dtypes/__init__.py (TEMPORARY DEBUG)
print(f"DEBUG: Inside __init__, JSONArray type: {type(JSONArray)}, value: {repr(JSONArray)}")
print(f"DEBUG: Inside __init__, JSONDtype type: {type(JSONDtype)}, value: {repr(JSONDtype)}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll want to remove these before merging.

Suggested change
# Inside db_dtypes/__init__.py (TEMPORARY DEBUG)
print(f"DEBUG: Inside __init__, JSONArray type: {type(JSONArray)}, value: {repr(JSONArray)}")
print(f"DEBUG: Inside __init__, JSONDtype type: {type(JSONDtype)}, value: {repr(JSONDtype)}")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 364 to 373
if sys_major == 3 and sys_minor in (7, 8):
warnings.warn(
"The python-bigquery library as well as the python-db-dtypes-pandas library no "
"longer supports Python 3.7 and Python 3.8. "
f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
"recommend that you update soon to ensure ongoing support. For "
"more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
FutureWarning,
stacklevel=2, # Point warning to the caller of __init__
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you use python_requires in setup.py, I'm having a hard time seeing how someone could end up in this state.

Do we want to issue this in a separate PR and release so folks see it before fully dropping?

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 can do that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 376 to 386
# sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version()
# if sys_major == 3 and sys_minor in (7, 8):
# warnings.warn(
# "The python-bigquery library as well as the python-db-dtypes-pandas library no "
# "longer supports Python 3.7 and Python 3.8. "
# f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
# "recommend that you update soon to ensure ongoing support. For "
# "more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
# FutureWarning,
# )

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove this commented out code.

Suggested change
# sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version()
# if sys_major == 3 and sys_minor in (7, 8):
# warnings.warn(
# "The python-bigquery library as well as the python-db-dtypes-pandas library no "
# "longer supports Python 3.7 and Python 3.8. "
# f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
# "recommend that you update soon to ensure ongoing support. For "
# "more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
# FutureWarning,
# )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

_check_python_version()

# Assign __all__ by calling the function
__all__ = _determine_all(JSONArray, JSONDtype)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems a bit too "magic" to me, but I suppose it could make testing easier?

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 code was originally just in the file with no function def. We added _check_python_version...

To test against supported and unsupported versions we attempted to mock the version but timing became an issue, partly because dependencies also rely on version checks so our mock ended up preventing error-free installs of some dependencies.

We tried half a dozen ways to alter when the mock happened but none hit that sweet spot of reliably allowing the dependencies to do their thing and slipping in to allow our test to run.

Similarly, we ran into a mess of problems with import timing and mocking whether JSONArray JSONDtype did or did not import as expected and so ...

putting them in functions made things much easier in the testing arena.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any hard feelings if we resolve this conversation?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure to update constraints-3.9.txt with our minimum supported package versions from setup.py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -24,7 +24,7 @@
import pytest

# NDArrayBacked2DTests suite added in https://github.com/pandas-dev/pandas/pull/44974
pytest.importorskip("pandas", minversion="1.5.0dev")
pytest.importorskip("pandas")
Copy link
Collaborator

Choose a reason for hiding this comment

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

pandas is a strict dependency. I don't think we need this line. We were just using it for the min version before.

Suggested change
pytest.importorskip("pandas")

Copy link
Collaborator Author

@chalmerlowe chalmerlowe Apr 30, 2025

Choose a reason for hiding this comment

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

Since we rely on pandas version >=1.5.0 this whole file feels unnecessary.

  • I am gonna move this test to the generic date_compliance file
  • I will delete this 1_5 date_compliance-specific file
  • I am gonna move a similar test from test_time_compliance_1_5.py to the generic time_compliance file
  • I will delete this 1_5 time_compliance-specific file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -24,7 +24,7 @@
import pytest

# NDArrayBacked2DTests suite added in https://github.com/pandas-dev/pandas/pull/44974
pytest.importorskip("pandas", minversion="1.5.0dev")
pytest.importorskip("pandas")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

Suggested change
pytest.importorskip("pandas")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comment above about date_compliance.

Done.

@@ -0,0 +1,137 @@
import sys
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing license header.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 2 to 6
import pytest
import types
import warnings
from unittest import mock
import pyarrow as pa
Copy link
Collaborator

Choose a reason for hiding this comment

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

Imports should be grouped in the following order:

  1. Standard library imports.
  2. Related third party imports.
  3. Local application/library specific imports.

You should put a blank line between each group of imports.

https://peps.python.org/pep-0008/#imports

Suggested change
import pytest
import types
import warnings
from unittest import mock
import pyarrow as pa
import types
import warnings
from unittest import mock
import pyarrow as pa
import pytest

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@chalmerlowe chalmerlowe added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 30, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 30, 2025
@chalmerlowe chalmerlowe added the owlbot:run Add this label to trigger the Owlbot post processor. label May 1, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 1, 2025
@chalmerlowe chalmerlowe added owlbot:run Add this label to trigger the Owlbot post processor. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels May 2, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 2, 2025
@chalmerlowe
Copy link
Collaborator Author

chalmerlowe commented May 2, 2025

@tswast or @Linchin

Can you confirm comment resolution? And if you feel comfortable, approve?

I am unable to get Owlbot to run without failing. Dunno why. Wonder if it is because the PR was generated by Jules. (But I can generally get Owlbot to run/pass, so... weird).

There is a class in pandas_backports.py that did not have tests (and which fact coverage ignored apparently). For the purposes of this PR I consider adding the tests to be out of scope. So I flagged the class as # pragma: NO COVER

There are a pair of code branches that for the life of me, no matter what I tried, I could not get coverage to acknowledge that the code was covered despite confirming that those lines of code did execute. I flagged both of those with # pragma: NO COVER

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. samples Issues that are directly related to samples. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants