Skip to content

Commit 07632cf

Browse files
committed
Add Py 3.14, drop Py < 3.12. Make Acquisition optional.
1 parent 15ea23f commit 07632cf

5 files changed

Lines changed: 37 additions & 29 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ jobs:
2525
strategy:
2626
matrix:
2727
python-version:
28-
- "pypy-3.10"
29-
- "3.11"
3028
- "3.12"
3129
- "3.13"
30+
- "3.14"
3231
extras:
3332
- "[test,docs]"
3433
# include:

CHANGES.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Changes
33
=========
44

5-
1.18.1 (unreleased)
5+
1.19.0 (unreleased)
66
===================
77

8-
- Nothing changed yet.
8+
- Add support for Python 3.14; drop Python < 3.12.
9+
- Acquisition is now an optional dependency, not installed by default.
910

1011

1112
1.18.0 (2024-11-18)

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ def _read(fname):
3636
'Operating System :: OS Independent',
3737
'Programming Language :: Python :: 3',
3838
'Programming Language :: Python :: 3 :: Only',
39-
'Programming Language :: Python :: 3.9',
40-
'Programming Language :: Python :: 3.10',
41-
'Programming Language :: Python :: 3.11',
4239
'Programming Language :: Python :: 3.12',
4340
'Programming Language :: Python :: 3.13',
41+
'Programming Language :: Python :: 3.14',
4442
'Programming Language :: Python :: Implementation :: CPython',
4543
'Programming Language :: Python :: Implementation :: PyPy',
4644
'Framework :: Zope3',
@@ -50,7 +48,6 @@ def _read(fname):
5048
include_package_data=True,
5149
zip_safe=True,
5250
install_requires=[
53-
'Acquisition',
5451
'nti.i18n >= 1.1.0',
5552
'zope.event',
5653
'zope.interface >= 5.0.0',
@@ -74,8 +71,9 @@ def _read(fname):
7471
'nti.testing',
7572
'repoze.sphinx.autointerface',
7673
'sphinx_rtd_theme',
74+
'Acquisition',
7775
],
7876
},
7977
entry_points=entry_points,
80-
python_requires=">=3.10",
78+
python_requires=">=3.12",
8179
)

src/nti/schema/fieldproperty.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,36 @@
99
# stdlib imports
1010
import sys
1111

12-
from Acquisition import aq_base
13-
from Acquisition.interfaces import IAcquirer
12+
1413
from zope.schema import interfaces as sch_interfaces
1514
from zope.schema.fieldproperty import FieldProperty
1615
from zope.schema.fieldproperty import FieldPropertyStoredThroughField
1716
from zope.schema.fieldproperty import createFieldProperties
1817

1918
__docformat__ = "restructuredtext en"
2019

21-
class AcquisitionFieldProperty(FieldProperty):
22-
"""
23-
A field property that supports acquisition. Returned objects
24-
will be ``__of__`` the instance, and set objects will always be the unwrapped
25-
base.
26-
"""
27-
28-
def __get__(self, instance, klass):
29-
result = super().__get__(instance, klass)
30-
# pylint:disable-next=no-value-for-parameter
31-
if instance is not None and IAcquirer.providedBy(result): # even defaults get wrapped
32-
result = result.__of__(instance)
33-
return result
20+
try:
21+
from Acquisition import aq_base
22+
from Acquisition.interfaces import IAcquirer
23+
except ModuleNotFoundError:
24+
pass
25+
else:
26+
class AcquisitionFieldProperty(FieldProperty):
27+
"""
28+
A field property that supports acquisition. Returned objects
29+
will be ``__of__`` the instance, and set objects will always be the unwrapped
30+
base.
31+
"""
32+
33+
def __get__(self, instance, klass):
34+
result = super().__get__(instance, klass)
35+
# pylint:disable-next=no-value-for-parameter
36+
if instance is not None and IAcquirer.providedBy(result): # even defaults get wrapped
37+
result = result.__of__(instance)
38+
return result
3439

35-
def __set__(self, instance, value):
36-
super().__set__(instance, aq_base(value))
40+
def __set__(self, instance, value):
41+
super().__set__(instance, aq_base(value))
3742

3843
class UnicodeConvertingFieldProperty(FieldProperty):
3944
"""

src/nti/schema/tests/test_fieldproperty.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
import doctest
1313
import unittest
1414

15-
from Acquisition import Implicit
16-
from ExtensionClass import Base
15+
1716
from zope.interface import Interface
1817
from zope.interface import implementer
1918
from zope.schema.interfaces import SchemaNotProvided
2019
from zope.schema.interfaces import WrongType
2120

2221
from nti.schema.field import Object
2322
from nti.schema.field import ValidTextLine as TextLine
24-
from nti.schema.fieldproperty import AcquisitionFieldProperty
2523
from nti.schema.fieldproperty import AdaptingFieldProperty
2624
from nti.schema.fieldproperty import AdaptingFieldPropertyStoredThroughField
2725
from nti.schema.fieldproperty import UnicodeConvertingFieldProperty
@@ -50,6 +48,13 @@
5048
class TestAqFieldProperty(unittest.TestCase):
5149

5250
def test_aq_property(self):
51+
try:
52+
from Acquisition import Implicit
53+
from ExtensionClass import Base
54+
except ModuleNotFoundError:
55+
self.skipTest('Acquisition not installed')
56+
57+
from nti.schema.fieldproperty import AcquisitionFieldProperty
5358

5459
class IBaz(Interface):
5560
pass

0 commit comments

Comments
 (0)