-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Changes from 16 commits
9b32164
dccef48
f81c738
5cb30ca
7f44424
3e4e6f6
7beea0d
32d7b8f
e871d73
2bdf3ef
d902e31
a0543b9
6a5d943
1bbd5f7
96a5e97
8af9bee
78574c0
9ca34b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,14 +21,14 @@ | |||||||||||||||||||||
import warnings | ||||||||||||||||||||||
|
||||||||||||||||||||||
import numpy | ||||||||||||||||||||||
import packaging.version | ||||||||||||||||||||||
import pandas | ||||||||||||||||||||||
import pandas.api.extensions | ||||||||||||||||||||||
from pandas.errors import OutOfBoundsDatetime | ||||||||||||||||||||||
import pyarrow | ||||||||||||||||||||||
import pyarrow.compute | ||||||||||||||||||||||
|
||||||||||||||||||||||
from db_dtypes import core | ||||||||||||||||||||||
from db_dtypes.json import JSONArray, JSONArrowType, JSONDtype | ||||||||||||||||||||||
from db_dtypes.version import __version__ | ||||||||||||||||||||||
|
||||||||||||||||||||||
from . import _versions_helpers | ||||||||||||||||||||||
|
@@ -47,15 +47,6 @@ | |||||||||||||||||||||
_NP_BOX_DTYPE = "datetime64[us]" | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
# To use JSONArray and JSONDtype, you'll need Pandas 1.5.0 or later. With the removal | ||||||||||||||||||||||
# of Python 3.7 compatibility, the minimum Pandas version will be updated to 1.5.0. | ||||||||||||||||||||||
if packaging.version.Version(pandas.__version__) >= packaging.version.Version("1.5.0"): | ||||||||||||||||||||||
from db_dtypes.json import JSONArray, JSONArrowType, JSONDtype | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
JSONArray = None | ||||||||||||||||||||||
JSONDtype = None | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
@pandas.api.extensions.register_extension_dtype | ||||||||||||||||||||||
class TimeDtype(core.BaseDatetimeDtype): | ||||||||||||||||||||||
""" | ||||||||||||||||||||||
|
@@ -346,35 +337,55 @@ def __sub__(self, other): | |||||||||||||||||||||
|
||||||||||||||||||||||
return super().__sub__(other) | ||||||||||||||||||||||
|
||||||||||||||||||||||
# 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)}") | ||||||||||||||||||||||
|
||||||||||||||||||||||
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 will stop supporting Python 3.7 " | ||||||||||||||||||||||
"and Python 3.8 in a future major release expected in Q4 2024. " | ||||||||||||||||||||||
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)", | ||||||||||||||||||||||
PendingDeprecationWarning, | ||||||||||||||||||||||
) | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
if not JSONArray or not JSONDtype: | ||||||||||||||||||||||
__all__ = [ | ||||||||||||||||||||||
def _determine_all(json_array_type, json_dtype_type): | ||||||||||||||||||||||
"""Determines the list for __all__ based on JSON type availability.""" | ||||||||||||||||||||||
base_all = [ | ||||||||||||||||||||||
"__version__", | ||||||||||||||||||||||
"DateArray", | ||||||||||||||||||||||
"DateDtype", | ||||||||||||||||||||||
"TimeArray", | ||||||||||||||||||||||
"TimeDtype", | ||||||||||||||||||||||
] | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
__all__ = [ | ||||||||||||||||||||||
"__version__", | ||||||||||||||||||||||
"DateArray", | ||||||||||||||||||||||
"DateDtype", | ||||||||||||||||||||||
"JSONDtype", | ||||||||||||||||||||||
"JSONArray", | ||||||||||||||||||||||
"JSONArrowType", | ||||||||||||||||||||||
"TimeArray", | ||||||||||||||||||||||
"TimeDtype", | ||||||||||||||||||||||
] | ||||||||||||||||||||||
# Check if both JSON types are available (truthy) | ||||||||||||||||||||||
if json_array_type and json_dtype_type: | ||||||||||||||||||||||
# print("DEBUG: Condition FALSE, including JSON in __all__") # Keep if needed | ||||||||||||||||||||||
return base_all + ["JSONDtype", "JSONArray", "JSONArrowType"] | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
# print("DEBUG: Condition TRUE, excluding JSON from __all__") # Keep if needed | ||||||||||||||||||||||
return base_all | ||||||||||||||||||||||
|
||||||||||||||||||||||
def _check_python_version(): | ||||||||||||||||||||||
"""Checks the runtime Python version and issues a warning if needed.""" | ||||||||||||||||||||||
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, | ||||||||||||||||||||||
stacklevel=2, # Point warning to the caller of __init__ | ||||||||||||||||||||||
) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you use Do we want to issue this in a separate PR and release so folks see it before fully dropping? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do that. |
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
# 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, | ||||||||||||||||||||||
# ) | ||||||||||||||||||||||
|
||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this commented out code.
Suggested change
|
||||||||||||||||||||||
# Perform the version check | ||||||||||||||||||||||
_check_python_version() | ||||||||||||||||||||||
|
||||||||||||||||||||||
# Assign __all__ by calling the function | ||||||||||||||||||||||
__all__ = _determine_all(JSONArray, JSONDtype) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
There was a problem hiding this comment.
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.