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 18 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)}")

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.

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,
# )

_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.

Comment on lines +283 to +284
# Type 'dbjson' might already be registered if the module is reloaded,
# which is okay.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this could be a separate PR since it's a fix for an issue unrelated to 3.7/3.8 support.

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 was direct result of coverage blowing up.
I tried to fix a few things to restore coverage and it all went downhill from there, hence our convo in chat this AM.

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.

@@ -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")

@@ -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")

@@ -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.

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

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. do not merge Indicates a pull request not ready for merge, due to either quality or timing. 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.

3 participants