dbt-labs/dbt-core

[CT-3325] [Tech Debt][Spike] Test `dbt-core` with Python 3.12

aranke opened this issue · 4 comments

aranke commented

Housekeeping

  • I am a maintainer of dbt-core

Short description

Python 3.12 was released last month, let's test that dbt-core works with this

https://www.python.org/downloads/release/python-3120/

Acceptance criteria

Bundles can be created with Python 3.12

Impact to Other Teams

Ideally none

Will backports be required?

No

Context

No response

Deprecation notices appear when you run dbt init with dbt-postgres with Python 3.12:

dbt init -h
/Users/sam/.pyenv/versions/3.12.0/envs/myproject-dbt/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
<frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.
<frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.
Usage: dbt init [OPTIONS] [PROJECT_NAME]
...

I get the warning when I run dbt debug - also using dbt-postgres and Python 3.12

dbt debug
DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
<frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.
<frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

I get the warning when I run dbt debug - also using dbt-postgres and Python 3.12

dbt debug
DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
<frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.
<frozen importlib._bootstrap>:488: DeprecationWarning: Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.

FWIW those seem to come from dependencies rather than dbt-core itself.

Hi folks - I identified a new problem with dbt-core and Python 3.12.1.

3.12 formally removed distutils, which was deprecated in 3.10. This removal wasn't fully implemented until 3.12.1, which released this week. The distutils import strtobool is used in dbt-core in two places - here and here. While some other functions of distutils were moved to other standard Python packages/functions/modules, strtobool was not and the PEP 632 migration guide suggests that project maintainers reimplement its functionality.