Skip to content
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

- Add support for Python 3.12, 3.13. - Drop support for Python 3.7. #83

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
name: pre-commit

on:
pull_request:
push:
branches:
- master
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:

env:
FORCE_COLOR: 1

jobs:
pre-commit:
name: linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --show-diff-on-failure
env:
PRE_COMMIT_COLOR: always
- uses: pre-commit-ci/lite-action@v1.0.2
if: always()
with:
msg: Apply pre-commit code formatting
28 changes: 17 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ jobs:
fail-fast: false
matrix:
os:
- ["ubuntu", "ubuntu-20.04"]
- ["ubuntu", "ubuntu-latest"]
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.9", "coverage"]
- ["3.11", "release-check"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.12", "py312"]
- ["3.13", "py313"]
- ["3.11", "coverage"]

runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand All @@ -42,13 +43,14 @@ jobs:
sudo su - postgres -c '/usr/lib/postgresql/14/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start'
sudo su - postgres -c '/usr/lib/postgresql/14/bin/createdb zope_sqlalchemy_tests'
sudo su - postgres -c '/usr/lib/postgresql/14/bin/psql -l'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config[0] }}
allow-prereleases: true
- name: Pip cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
Expand All @@ -60,8 +62,12 @@ jobs:
python -m pip install --upgrade pip
pip install tox
- name: Test
if: ${{ !startsWith(runner.os, 'Mac') }}
run: |
tox -f ${{ matrix.config[1] }}
- name: Test (macOS)
if: ${{ startsWith(runner.os, 'Mac') }}
run: tox -e ${{ matrix.config[1] }}-universal2
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
Expand Down
9 changes: 5 additions & 4 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[meta]
template = "zope-product"
commit-id = "1dc6b9e7"
commit-id = "85622de1"

[python]
with-pypy = false
with-sphinx-doctests = false
with-windows = false
with-future-python = false
with-macos = false
with-docs = false

[coverage]
fail-under = 65

[tox]
additional-envlist = [
"py{37,38,39}-sqlalchemy11",
"py{37,38,39,310}-sqlalchemy{12,13}",
"py{37,38,39,310,311}-sqlalchemy{14,20}",
"py{38,39}-sqlalchemy11",
"py{38,39,310}-sqlalchemy{12,13}",
"py{38,39,310,311,312,313}-sqlalchemy{14,20}",
]
testenv-deps = [
"sqlalchemy11: SQLAlchemy==1.1.*",
Expand Down
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
minimum_pre_commit_version: '3.6'
repos:
- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: isort
- repo: https://github.com/hhatto/autopep8
rev: "v2.3.1"
hooks:
- id: autopep8
args: [--in-place, --aggressive, --aggressive]
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/isidentical/teyit
rev: 0.4.3
hooks:
- id: teyit
- repo: https://github.com/PyCQA/flake8
rev: "7.1.1"
hooks:
- id: flake8
additional_dependencies:
- flake8-debugger == 4.1.2
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changes
3.2 (unreleased)
dataflake marked this conversation as resolved.
Show resolved Hide resolved
----------------

- Add support for Python 3.12, 3.13.

- Drop support for Python 3.7.

- SQLAlchemy's versions 2.0.32 up to 2.0.35 run into dead locks when running
the tests on Python 3.11+, so excluding them from the list of supported
versions.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include *.rst
include *.txt
include buildout.cfg
include tox.ini
include .pre-commit-config.yaml

recursive-include src *.py
include github_actions.cfg
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product

[build-system]
requires = ["setuptools<74"]
build-backend = "setuptools.build_meta"

[tool.coverage]
[tool.coverage.run]
branch = true
source = ["zope.sqlalchemy"]

[tool.coverage.report]
fail_under = 65
precision = 2
ignore_errors = true
show_missing = true
exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"]

[tool.coverage.html]
directory = "parts/htmlcov"
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[bdist_wheel]
universal = 0

[flake8]
doctests = 1
Expand All @@ -17,7 +15,7 @@ ignore =
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources, pytz
known_third_party = docutils, pkg_resources, pytz
known_zope =
known_first_party =
default_section = ZOPE
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
namespace_packages=['zope'],
test_suite='zope.sqlalchemy.tests.test_suite',
author='Laurence Rowe',

author_email='laurence@lrowe.co.uk',
url='https://github.com/zopefoundation/zope.sqlalchemy',
description="Minimal Zope/SQLAlchemy transaction integration",
long_description=(
open(os.path.join('src', 'zope', 'sqlalchemy', 'README.rst')).read() +
"\n\n" +
open('CHANGES.rst').read()),
"\n\n" + open('CHANGES.rst').read()),
license='ZPL 2.1',
keywords='zope zope3 sqlalchemy',
classifiers=[
Expand All @@ -35,16 +33,17 @@
"License :: OSI Approved :: Zope Public License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Database",
"Topic :: Software Development :: Libraries :: Python Modules",
],
python_requires='>=3.7',
python_requires='>=3.8',
install_requires=[
'packaging',
'setuptools',
Expand Down
47 changes: 32 additions & 15 deletions src/zope/sqlalchemy/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def testMarkUnknownSession(self):
DummyDataManager(key="dummy.first")
session = Session()
mark_changed(session)
self.assertTrue(session in zope.sqlalchemy.datamanager._SESSION_STATE)
self.assertIn(session, zope.sqlalchemy.datamanager._SESSION_STATE)

def testAbortBeforeCommit(self):
# Simulate what happens in a conflict error
Expand Down Expand Up @@ -399,18 +399,27 @@ def testSavepoint(self):
s1 = t.savepoint()
session.add(User(id=1, firstname="udo", lastname="juergens"))
session.flush()
self.assertTrue(len(query.all()) == 1,
"Users table should have one row")
self.assertEqual(
len(query.all()),
1,
"Users table should have one row"
)

s2 = t.savepoint()
session.add(User(id=2, firstname="heino", lastname="n/a"))
session.flush()
self.assertTrue(len(query.all()) == 2,
"Users table should have two rows")
self.assertEqual(
len(query.all()),
2,
"Users table should have two rows"
)

s2.rollback()
self.assertTrue(len(query.all()) == 1,
"Users table should have one row")
self.assertEqual(
len(query.all()),
1,
"Users table should have one row"
)

s1.rollback()
self.assertFalse(query.all(), "Users table should be empty")
Expand Down Expand Up @@ -771,12 +780,16 @@ def testRetry(self):
tm1, tm2, s1, s2 = self.tm1, self.tm2, self.s1, self.s2
# make sure we actually start a session.
tm1.begin()
self.assertTrue(
len(s1.query(User).all()) == 1, "Users table should have one row"
self.assertEqual(
len(s1.query(User).all()),
1,
"Users table should have one row"
)
tm2.begin()
self.assertTrue(
len(s2.query(User).all()) == 1, "Users table should have one row"
self.assertEqual(
len(s2.query(User).all()),
1,
"Users table should have one row"
)
s1.query(User).delete()
if SA_GE_20:
Expand All @@ -800,15 +813,19 @@ def testRetryThread(self):
tm1, tm2, s1, s2 = self.tm1, self.tm2, self.s1, self.s2
# make sure we actually start a session.
tm1.begin()
self.assertTrue(
len(s1.query(User).all()) == 1, "Users table should have one row"
self.assertEqual(
len(s1.query(User).all()),
1,
"Users table should have one row"
)
tm2.begin()
s2.connection().execute(sql.text(
"SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"
))
self.assertTrue(
len(s2.query(User).all()) == 1, "Users table should have one row"
self.assertEqual(
len(s2.query(User).all()),
1,
"Users table should have one row"
)
s1.query(User).delete()
raised = False
Expand Down
Loading
Loading