Skip to content

Commit

Permalink
Update Python version support. (#156)
Browse files Browse the repository at this point in the history
* Add support for Python 3.13.
  • Loading branch information
icemac authored Dec 3, 2024
1 parent 751bd3d commit bc3fb48
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 110 deletions.
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/[email protected]
with:
extra_args: --all-files --show-diff-on-failure
env:
PRE_COMMIT_COLOR: always
- uses: pre-commit-ci/[email protected]
if: always()
with:
msg: Apply pre-commit code formatting
22 changes: 11 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ jobs:
- ["macos", "macos-latest"]
config:
# [Python version, tox env]
- ["3.11", "release-check"]
- ["3.11", "lint"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.12", "py312"]
- ["3.11", "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"]
exclude:
- { os: ["macos", "macos-latest"], config: ["3.11", "release-check"] }
- { os: ["macos", "macos-latest"], config: ["3.11", "lint"] }
- { os: ["macos", "macos-latest"], config: ["3.11", "coverage"] }
- { os: ["macos", "macos-latest"], config: ["3.11", "release-check"] }
- { os: ["macos", "macos-latest"], config: ["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 @@ -43,6 +42,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config[0] }}
allow-prereleases: true
- name: Pip cache
uses: actions/cache@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/zopefoundation/meta/tree/master/config/zope-product
[meta]
template = "zope-product"
commit-id = "c412f00f"
commit-id = "baf6089f"

[python]
with-pypy = false
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
7.2 (unreleased)
----------------

- Add support for Python 3.13.

- Drop support for Python 3.7.


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
recursive-include src *.dtml
Expand Down
2 changes: 1 addition & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parts =

[versions]
Products.ZCatalog =
RestrictedPython = >= 5.1


[interpreter]
recipe = zc.recipe.egg
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/zope-product

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

[tool.coverage.run]
branch = true
source = ["Products.ZCatalog"]

[tool.coverage.report]
fail_under = 85
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"
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"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 :: Internet :: WWW/HTTP :: Indexing/Search",
],
Expand Down
12 changes: 6 additions & 6 deletions src/Products/PluginIndexes/BooleanIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ def test_index_true(self):
index = self._makeOne()
obj = Dummy(1, True)
index._index_object(obj.id, obj, attr='truth')
self.assertTrue(1 in index._unindex)
self.assertFalse(1 in index._index)
self.assertIn(1, index._unindex)
self.assertNotIn(1, index._index)

def test_index_false(self):
index = self._makeOne()
obj = Dummy(1, False)
index._index_object(obj.id, obj, attr='truth')
self.assertTrue(1 in index._unindex)
self.assertFalse(1 in index._index)
self.assertIn(1, index._unindex)
self.assertNotIn(1, index._index)

def test_index_missing_attribute(self):
index = self._makeOne()
obj = Dummy(1, True)
index._index_object(obj.id, obj, attr='missing')
self.assertFalse(1 in index._unindex)
self.assertFalse(1 in index._index)
self.assertNotIn(1, index._unindex)
self.assertNotIn(1, index._index)

def test_search_true(self):
index = self._makeOne()
Expand Down
16 changes: 8 additions & 8 deletions src/Products/PluginIndexes/DateIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def checkApply():
self.assertEqual(len(result), len(expectedValues),
f'{req}: {result} | {expectedValues}')
for k, v in expectedValues:
self.assertTrue(k in result)
self.assertIn(k, result)

cache = index.getRequestCache()
cache.clear()
Expand Down Expand Up @@ -221,16 +221,16 @@ def test_empty(self):
self.assertEqual(len(index), 0)
self.assertEqual(len(index.referencedObjects()), 0)

self.assertTrue(index.getEntryForObject(1234) is None)
self.assertIsNone(index.getEntryForObject(1234))
marker = []
self.assertTrue(index.getEntryForObject(1234, marker) is marker)
self.assertIs(index.getEntryForObject(1234, marker), marker)
index.unindex_object(1234) # shouldn't throw

self.assertTrue(index.hasUniqueValuesFor('date'))
self.assertFalse(index.hasUniqueValuesFor('foo'))
self.assertEqual(len(list(index.uniqueValues('date'))), 0)

self.assertTrue(index._apply_index({'zed': 12345}) is None)
self.assertIsNone(index._apply_index({'zed': 12345}))

self._checkApply(index,
{'date': DateTime(0)}, [])
Expand Down Expand Up @@ -260,9 +260,9 @@ def test_retrieval(self):
# One empty
self.assertEqual(len(index.referencedObjects()), len(values) - 1)

self.assertTrue(index.getEntryForObject(1234) is None)
self.assertIsNone(index.getEntryForObject(1234))
marker = []
self.assertTrue(index.getEntryForObject(1234, marker) is marker)
self.assertIs(index.getEntryForObject(1234, marker), marker)
index.unindex_object(1234) # shouldn't throw

for k, v in values:
Expand All @@ -272,7 +272,7 @@ def test_retrieval(self):

self.assertEqual(
len(list(index.uniqueValues('date'))), len(values) - 2)
self.assertTrue(index._apply_index({'bar': 123}) is None)
self.assertIsNone(index._apply_index({'bar': 123}))

self._checkApply(index,
{'date': DateTime(0)}, values[1:2])
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_removal(self):
self._checkApply(index,
{'date': 1072742900}, [values[7]])
index.index_object(7, None)
self.assertFalse(7 in index.documentToKeyMap().keys())
self.assertNotIn(7, index.documentToKeyMap().keys())

def test_getCounter(self):
from DateTime import DateTime
Expand Down
8 changes: 4 additions & 4 deletions src/Products/PluginIndexes/DateRangeIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ def test_interfaces(self):
def test_empty(self):
empty = self._makeOne('empty')

self.assertTrue(empty.getEntryForObject(1234) is None)
self.assertIsNone(empty.getEntryForObject(1234))
empty.unindex_object(1234) # shouldn't throw

self.assertFalse(list(empty.uniqueValues('foo')))
self.assertFalse(list(empty.uniqueValues('foo', withLengths=True)))
self.assertTrue(empty._apply_index({'zed': 12345}) is None)
self.assertIsNone(empty._apply_index({'zed': 12345}))

self._checkApply(empty, {'empty': 12345}, [])

Expand Down Expand Up @@ -193,14 +193,14 @@ def test_floor_date(self):
floor = index.floor_value - 1
bad = Dummy('bad', floor, None)
index.index_object(0, bad)
self.assertTrue(0 in index._always.keys())
self.assertIn(0, index._always.keys())

def test_ceiling_date(self):
index = self._makeOne('work', 'start', 'stop')
ceiling = index.ceiling_value + 1
bad = Dummy('bad', None, ceiling)
index.index_object(1, bad)
self.assertTrue(1 in index._always.keys())
self.assertIn(1, index._always.keys())

def test_datetime(self):
from Products.PluginIndexes.DateIndex.tests import _getEastern
Expand Down
4 changes: 2 additions & 2 deletions src/Products/PluginIndexes/FieldIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def checkApply():
assert len(result) == len(expectedValues), \
f'{list(result)} | {expectedValues}'
for k, v in expectedValues:
self.assertTrue(k in result)
self.assertIn(k, result)

index = self._index

Expand Down Expand Up @@ -214,7 +214,7 @@ def testPopulated(self):
def testNone(self):
# Make sure None is ignored.
self._index.index_object(10, Dummy(None))
self.assertFalse(None in self._index.uniqueValues('foo'))
self.assertNotIn(None, self._index.uniqueValues('foo'))
self._checkApply({'foo': None}, [])

def testReindexNone(self):
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PluginIndexes/PathIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_getEntryForObject_miss_no_default(self):
def test_getEntryForObject_miss_w_default(self):
index = self._makeOne()
default = object()
self.assertTrue(index.getEntryForObject(1234, default) is default)
self.assertIs(index.getEntryForObject(1234, default), default)

def test_getEntryForObject_hit(self):
index = self._makeOne()
Expand Down
6 changes: 3 additions & 3 deletions src/Products/PluginIndexes/UUIDIndex/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def checkApply():
self.assertEqual(used, ('foo', ))
self.assertEqual(len(result), len(expectedValues))
for k, v in expectedValues:
self.assertTrue(k in result)
self.assertIn(k, result)

index = self._index

Expand Down Expand Up @@ -134,7 +134,7 @@ def test_populated(self):
values = self._values
self.assertEqual(len(self._index), len(values))
self.assertEqual(self._index.indexSize(), len(values))
self.assertTrue(self._index.getEntryForObject(10) is None)
self.assertIsNone(self._index.getEntryForObject(10))
self._checkApply({'foo': 'not'}, [])

self._index.unindex_object(10) # nothrow
Expand All @@ -156,7 +156,7 @@ def test_populated(self):
def test_none(self):
# Make sure None is ignored.
self._index.index_object(10, Dummy(None))
self.assertFalse(None in self._index.uniqueValues('foo'))
self.assertNotIn(None, self._index.uniqueValues('foo'))
self._checkApply({'foo': None}, [])

def test_reindex(self):
Expand Down
8 changes: 4 additions & 4 deletions src/Products/ZCTextIndex/tests/testLexicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def process_post_glob(self, lst):
wids = lexicon.sourceToWordIds('cats and dogs')
wids = lexicon.termToWordIds('dogs')
self.assertEqual(len(wids), 1)
self.assertTrue(wids[0] > 0)
self.assertGreater(wids[0], 0)

def testMissingTermToWordIdsWithProcess_post_glob(self):
"""This test is for added process_post_glob"""
Expand All @@ -156,7 +156,7 @@ def testOnePipelineElement(self):
wids = lexicon.sourceToWordIds('cats and dogs')
wids = lexicon.termToWordIds('fish')
self.assertEqual(len(wids), 1)
self.assertTrue(wids[0] > 0)
self.assertGreater(wids[0], 0)

def testSplitterAdaptorFold(self):
from Products.ZCTextIndex.Lexicon import CaseNormalizer
Expand Down Expand Up @@ -189,7 +189,7 @@ def testTwoElementPipeline(self):
wids = lexicon.sourceToWordIds('cats and dogs')
wids = lexicon.termToWordIds('hsif')
self.assertEqual(len(wids), 1)
self.assertTrue(wids[0] > 0)
self.assertGreater(wids[0], 0)

def testThreeElementPipeline(self):
from Products.ZCTextIndex.Lexicon import Splitter
Expand All @@ -202,7 +202,7 @@ def testThreeElementPipeline(self):
wids = lexicon.sourceToWordIds('cats and dogs')
wids = lexicon.termToWordIds('hsif')
self.assertEqual(len(wids), 1)
self.assertTrue(wids[0] > 0)
self.assertGreater(wids[0], 0)

def testSplitterLocaleAwareness(self):
import locale
Expand Down
Loading

0 comments on commit bc3fb48

Please sign in to comment.