Skip to content

Commit 3f500ae

Browse files
authored
Merge pull request #748 from kurtmckee/update-python-support
Update supported Python versions
2 parents 30abfe2 + ab7662a commit 3f500ae

9 files changed

Lines changed: 46 additions & 38 deletions

File tree

.github/workflows/test.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ jobs:
66
fail-fast: false
77
matrix:
88
os: ['ubuntu-latest']
9-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
9+
python-version:
10+
- '3.9'
11+
- '3.10'
12+
- '3.11'
13+
- '3.12'
1014
tox_env: ['sqlalchemy14', 'sqlalchemy2']
1115
include:
12-
# Test against Python 3.7 and sqlalchemy 1.3
16+
# Test against Python 3.9 and sqlalchemy 1.3
1317
- os: 'ubuntu-20.04'
14-
python-version: '3.7'
18+
python-version: '3.9'
1519
tox_env: 'sqlalchemy13'
16-
# Test against Python 3.7 and sqlalchemy 1.4
20+
# Test against Python 3.9 and sqlalchemy 1.4
1721
- os: 'ubuntu-20.04'
18-
python-version: '3.7'
22+
python-version: '3.9'
1923
tox_env: 'sqlalchemy14'
2024
runs-on: ${{ matrix.os }}
2125
services:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ repos:
2828
rev: v3.17.0
2929
hooks:
3030
- id: pyupgrade
31-
args: [--py36-plus]
31+
args: [--py39-plus]

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Changelog
33

44
Here you can see the full list of changes between each SQLAlchemy-Utils release.
55

6+
Unreleased changes
7+
^^^^^^^^^^^^^^^^^^
8+
9+
- Drop support for Python 3.7 and 3.8.
10+
- Add support for Python 3.12.
11+
612
0.41.2 (2024-03-22)
713
^^^^^^^^^^^^^^^^^^^
814

docs/installation.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ This part of the documentation covers the installation of SQLAlchemy-Utils.
66
Supported platforms
77
-------------------
88

9-
SQLAlchemy-Utils is currently tested against the following Python platforms.
9+
SQLAlchemy-Utils is currently tested against the following Python platforms:
1010

11-
- cPython 3.7
12-
- cPython 3.8
13-
- cPython 3.9
14-
- cPython 3.10
15-
- cPython 3.11
11+
- CPython 3.9
12+
- CPython 3.10
13+
- CPython 3.11
14+
- CPython 3.12
1615

1716

1817
Installing an official release

setup.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,19 @@ def get_version():
7676
platforms='any',
7777
install_requires=[
7878
'SQLAlchemy>=1.3',
79-
"importlib_metadata ; python_version<'3.8'",
8079
],
8180
extras_require=extras_require,
82-
python_requires='>=3.7',
81+
python_requires='>=3.9',
8382
classifiers=[
8483
'Environment :: Web Environment',
8584
'Intended Audience :: Developers',
8685
'License :: OSI Approved :: BSD License',
8786
'Operating System :: OS Independent',
8887
'Programming Language :: Python',
89-
'Programming Language :: Python :: 3',
90-
'Programming Language :: Python :: 3.7',
91-
'Programming Language :: Python :: 3.8',
9288
'Programming Language :: Python :: 3.9',
9389
'Programming Language :: Python :: 3.10',
9490
'Programming Language :: Python :: 3.11',
91+
'Programming Language :: Python :: 3.12',
9592
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
9693
'Topic :: Software Development :: Libraries :: Python Modules'
9794
]

sqlalchemy_utils/compat.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import re
2-
import sys
3-
4-
if sys.version_info >= (3, 8):
5-
from importlib.metadata import metadata
6-
else:
7-
from importlib_metadata import metadata
2+
from importlib.metadata import metadata
83

94

105
def get_sqlalchemy_version(version=metadata("sqlalchemy")["Version"]):

sqlalchemy_utils/models.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import datetime, timezone
22

33
import sqlalchemy as sa
44

@@ -22,15 +22,23 @@ class SomeModel(Base, Timestamp):
2222
id = sa.Column(sa.Integer, primary_key=True)
2323
"""
2424

25-
created = sa.Column(sa.DateTime, default=datetime.utcnow, nullable=False)
26-
updated = sa.Column(sa.DateTime, default=datetime.utcnow, nullable=False)
25+
created = sa.Column(
26+
sa.DateTime,
27+
default=lambda: datetime.now(tz=timezone.utc).replace(tzinfo=None),
28+
nullable=False,
29+
)
30+
updated = sa.Column(
31+
sa.DateTime,
32+
default=lambda: datetime.now(tz=timezone.utc).replace(tzinfo=None),
33+
nullable=False,
34+
)
2735

2836

2937
@sa.event.listens_for(Timestamp, 'before_update', propagate=True)
3038
def timestamp_before_update(mapper, connection, target):
3139
# When a model with a timestamp is updated; force update the updated
3240
# timestamp.
33-
target.updated = datetime.utcnow()
41+
target.updated = datetime.now(tz=timezone.utc).replace(tzinfo=None)
3442

3543

3644
NOT_LOADED_REPR = '<not loaded>'

tests/test_models.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime
1+
from datetime import datetime, timezone
22

33
import pytest
44
import sqlalchemy as sa
@@ -17,26 +17,28 @@ class Article(Base, Timestamp):
1717
return Article
1818

1919
def test_created(self, session, Article):
20-
then = datetime.utcnow()
20+
then = datetime.now(tz=timezone.utc).replace(tzinfo=None)
2121
article = Article()
2222

2323
session.add(article)
2424
session.commit()
2525

26-
assert article.created >= then and article.created <= datetime.utcnow()
26+
assert article.created >= then
27+
assert article.created <= datetime.now(tz=timezone.utc).replace(tzinfo=None)
2728

2829
def test_updated(self, session, Article):
2930
article = Article()
3031

3132
session.add(article)
3233
session.commit()
3334

34-
then = datetime.utcnow()
35+
then = datetime.now(tz=timezone.utc).replace(tzinfo=None)
3536
article.name = "Something"
3637

3738
session.commit()
3839

39-
assert article.updated >= then and article.updated <= datetime.utcnow()
40+
assert article.updated >= then
41+
assert article.updated <= datetime.now(tz=timezone.utc).replace(tzinfo=None)
4042

4143

4244
class TestGenericRepr:

tox.ini

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
envlist =
3-
py{37, 38, 39, 310, 311}-sqlalchemy{13, 14, 2}
3+
py{3.9, 3.10, 3.11, 3.12}-sqlalchemy{13, 14, 2}
44
flake8
55
isort
66

@@ -46,15 +46,12 @@ commands = pre-commit run --hook-stage manual --all isort-check
4646
[pytest]
4747
filterwarnings =
4848
error
49-
; Ignore DeprecationWarnings caused by backports.zoneinfo (Python 3.6).
50-
ignore:open_text is deprecated. Use files\(\) instead.:DeprecationWarning
51-
ignore:open_binary is deprecated. Use files\(\) instead.:DeprecationWarning
5249
; Ignore ResourceWarnings caused by unclosed sockets in pg8000.
5350
; These are caught and re-raised as pytest.PytestUnraisableExceptionWarnings.
5451
ignore:Exception ignored:pytest.PytestUnraisableExceptionWarning
5552
; Ignore DeprecationWarnings caused by pg8000.
5653
ignore:distutils Version classes are deprecated.:DeprecationWarning
57-
; Ignore cryptography deprecation warnings (Python 3.6).
58-
ignore:Python 3.6 is no longer supported:UserWarning
5954
; Ignore warnings about passlib's use of the crypt module (Python 3.11).
6055
ignore:'crypt' is deprecated and slated for removal:DeprecationWarning
56+
; Ignore Python 3.12 UTC deprecation warnings caused by pendulum.
57+
ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning

0 commit comments

Comments
 (0)