Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 1ba4c3f

Browse files
authored
Update Python version support. (#10)
* Drop support for Python 3.7. * Add support for Python 3.13.
1 parent 0d2208e commit 1ba4c3f

13 files changed

+131
-64
lines changed

.github/workflows/pre-commit.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Generated from:
2+
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
3+
name: pre-commit
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- master
10+
# Allow to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
env:
14+
FORCE_COLOR: 1
15+
16+
jobs:
17+
pre-commit:
18+
name: linting
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: 3.x
25+
- uses: pre-commit/[email protected]
26+
with:
27+
extra_args: --all-files --show-diff-on-failure
28+
env:
29+
PRE_COMMIT_COLOR: always
30+
- uses: pre-commit-ci/[email protected]
31+
if: always()
32+
with:
33+
msg: Apply pre-commit code formatting

.github/workflows/tests.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os:
20-
- ["ubuntu", "ubuntu-20.04"]
20+
- ["ubuntu", "ubuntu-latest"]
2121
config:
2222
# [Python version, tox env]
23-
- ["3.9", "release-check"]
24-
- ["3.9", "lint"]
25-
- ["3.7", "py37"]
26-
- ["3.8", "py38"]
27-
- ["3.9", "py39"]
28-
- ["3.10", "py310"]
29-
- ["3.11", "py311"]
30-
- ["3.12", "py312"]
23+
- ["3.11", "release-check"]
24+
- ["3.8", "py38"]
25+
- ["3.9", "py39"]
26+
- ["3.10", "py310"]
27+
- ["3.11", "py311"]
28+
- ["3.12", "py312"]
29+
- ["3.13", "py313"]
3130
- ["pypy-3.10", "pypy3"]
32-
- ["3.9", "coverage"]
31+
- ["3.11", "coverage"]
3332

3433
runs-on: ${{ matrix.os[1] }}
3534
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
@@ -40,8 +39,9 @@ jobs:
4039
uses: actions/setup-python@v5
4140
with:
4241
python-version: ${{ matrix.config[0] }}
42+
allow-prereleases: true
4343
- name: Pip cache
44-
uses: actions/cache@v3
44+
uses: actions/cache@v4
4545
with:
4646
path: ~/.cache/pip
4747
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
@@ -53,7 +53,11 @@ jobs:
5353
python -m pip install --upgrade pip
5454
pip install tox
5555
- name: Test
56+
if: ${{ !startsWith(runner.os, 'Mac') }}
5657
run: tox -e ${{ matrix.config[1] }}
58+
- name: Test (macOS)
59+
if: ${{ startsWith(runner.os, 'Mac') }}
60+
run: tox -e ${{ matrix.config[1] }}-universal2
5761
- name: Coverage
5862
if: matrix.config[1] == 'coverage'
5963
run: |

.meta.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
33
[meta]
44
template = "pure-python"
5-
commit-id = "acd8d239"
5+
commit-id = "baf6089f"
66

77
[python]
88
with-windows = false
99
with-pypy = true
1010
with-future-python = false
1111
with-sphinx-doctests = false
1212
with-macos = false
13+
with-docs = false
1314

1415
[tox]
1516
use-flake8 = true
@@ -18,7 +19,7 @@ testenv-deps = [
1819
]
1920

2021
[coverage]
21-
fail-under = 99
22+
fail-under = 98.9
2223

2324
[manifest]
2425
additional-rules = [

.pre-commit-config.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated from:
2+
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
3+
minimum_pre_commit_version: '3.6'
4+
repos:
5+
- repo: https://github.com/pycqa/isort
6+
rev: "5.13.2"
7+
hooks:
8+
- id: isort
9+
- repo: https://github.com/hhatto/autopep8
10+
rev: "v2.3.1"
11+
hooks:
12+
- id: autopep8
13+
args: [--in-place, --aggressive, --aggressive]
14+
- repo: https://github.com/asottile/pyupgrade
15+
rev: v3.17.0
16+
hooks:
17+
- id: pyupgrade
18+
args: [--py38-plus]
19+
- repo: https://github.com/isidentical/teyit
20+
rev: 0.4.3
21+
hooks:
22+
- id: teyit
23+
- repo: https://github.com/PyCQA/flake8
24+
rev: "7.1.1"
25+
hooks:
26+
- id: flake8
27+
additional_dependencies:
28+
- flake8-debugger == 4.1.2

CHANGES.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ CHANGES
55
3.1 (unreleased)
66
----------------
77

8-
- Nothing changed yet.
8+
- Add support for Python 3.13.
9+
10+
- Drop support for Python 3.7.
911

1012

1113
3.0 (2024-01-11)

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include *.rst
55
include *.txt
66
include buildout.cfg
77
include tox.ini
8+
include .pre-commit-config.yaml
89

910
recursive-include src *.py
1011
recursive-include src *.rst

pyproject.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Generated from:
3+
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
4+
5+
[build-system]
6+
requires = ["setuptools < 74"]
7+
build-backend = "setuptools.build_meta"
8+
9+
[tool.coverage.run]
10+
branch = true
11+
source = ["z3c.macro"]
12+
13+
[tool.coverage.report]
14+
fail_under = 98.9
15+
precision = 2
16+
ignore_errors = true
17+
show_missing = true
18+
exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"]
19+
20+
[tool.coverage.html]
21+
directory = "parts/htmlcov"

setup.cfg

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Generated from:
22
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
3-
[bdist_wheel]
4-
universal = 0
53

64
[flake8]
75
doctests = 1

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ def read(*rnames):
6363
'License :: OSI Approved :: Zope Public License',
6464
'Programming Language :: Python',
6565
'Programming Language :: Python :: 3',
66-
'Programming Language :: Python :: 3.7',
6766
'Programming Language :: Python :: 3.8',
6867
'Programming Language :: Python :: 3.9',
6968
'Programming Language :: Python :: 3.10',
7069
'Programming Language :: Python :: 3.11',
7170
'Programming Language :: Python :: 3.12',
71+
'Programming Language :: Python :: 3.13',
7272
'Programming Language :: Python :: Implementation :: CPython',
7373
'Programming Language :: Python :: Implementation :: PyPy',
7474
'Natural Language :: English',
@@ -80,7 +80,7 @@ def read(*rnames):
8080
packages=find_packages('src'),
8181
package_dir={'': 'src'},
8282
namespace_packages=['z3c'],
83-
python_requires='>=3.7',
83+
python_requires='>=3.8',
8484
extras_require={
8585
'test': TESTS_REQUIRE,
8686
'chameleon': CHAMELEON_REQUIRES,

src/z3c/macro/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
from z3c.macro import tales
2929
z3c.pt.pagetemplate.BaseTemplate.expression_types[
3030
'macro'] = tales.MacroExpr
31-
except ImportError: # pragma: no cover
31+
except ModuleNotFoundError: # pragma: no cover
3232
# we do not support z3c.pt
3333
pass

src/z3c/macro/tales.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ def __call__(self, target, engine):
7070
traverse=self.traverser,
7171
)
7272

73-
except ImportError: # pragma: no cover
73+
except ModuleNotFoundError: # pragma: no cover
7474
pass

src/z3c/macro/zcml.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class IMacroDirective(zope.interface.Interface):
3636
(should end in extension ``.pt`` or ``.html``).
3737
""",
3838
required=True,
39-
)
39+
)
4040

4141
name = zope.schema.TextLine(
4242
title='Name',
@@ -53,7 +53,7 @@ class IMacroDirective(zope.interface.Interface):
5353
""",
5454
required=True,
5555
default='',
56-
)
56+
)
5757

5858
macro = zope.schema.TextLine(
5959
title='Macro',
@@ -64,14 +64,14 @@ class IMacroDirective(zope.interface.Interface):
6464
""",
6565
required=False,
6666
default='',
67-
)
67+
)
6868

6969
for_ = zope.configuration.fields.GlobalObject(
7070
title='Context',
7171
description='The context for which the macro should be used',
7272
required=False,
7373
default=zope.interface.Interface,
74-
)
74+
)
7575

7676
view = zope.configuration.fields.GlobalObject(
7777
title='View',
@@ -84,14 +84,14 @@ class IMacroDirective(zope.interface.Interface):
8484
description='The layer for which the macro should be used',
8585
required=False,
8686
default=IDefaultBrowserLayer,
87-
)
87+
)
8888

8989
contentType = zope.schema.ASCIILine(
9090
title='Content Type',
9191
description='The content type identifies the type of data.',
9292
default='text/html',
9393
required=False,
94-
)
94+
)
9595

9696

9797
class MacroFactory:

tox.ini

+17-38
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ minversion = 3.18
55
envlist =
66
release-check
77
lint
8-
py37
98
py38
109
py39
1110
py310
1211
py311
1312
py312
13+
py313
1414
pypy3
1515
coverage
1616

@@ -19,19 +19,25 @@ usedevelop = true
1919
package = wheel
2020
wheel_build_env = .pkg
2121
deps =
22+
setuptools < 74
2223
pypy3: cffi
23-
setenv =
24-
py312: VIRTUALENV_PIP=23.1.2
25-
py312: PIP_REQUIRE_VIRTUALENV=0
2624
commands =
2725
zope-testrunner --test-path=src {posargs:-vc}
2826
extras =
2927
test
28+
29+
[testenv:setuptools-latest]
30+
basepython = python3
31+
deps =
32+
git+https://github.com/pypa/setuptools.git\#egg=setuptools
33+
pypy3: cffi
34+
3035
[testenv:release-check]
3136
description = ensure that the distribution is ready to release
3237
basepython = python3
3338
skip_install = true
3439
deps =
40+
setuptools < 74
3541
twine
3642
build
3743
check-manifest
@@ -40,56 +46,29 @@ deps =
4046
commands_pre =
4147
commands =
4248
check-manifest
43-
check-python-versions
49+
check-python-versions --only setup.py,tox.ini,.github/workflows/tests.yml
4450
python -m build --sdist --no-isolation
4551
twine check dist/*
4652

4753
[testenv:lint]
54+
description = This env runs all linters configured in .pre-commit-config.yaml
4855
basepython = python3
4956
skip_install = true
5057
deps =
51-
isort
52-
flake8
53-
commands =
54-
isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py
55-
flake8 src setup.py
56-
57-
[testenv:isort-apply]
58-
basepython = python3
59-
skip_install = true
58+
pre-commit
6059
commands_pre =
61-
deps =
62-
isort
6360
commands =
64-
isort {toxinidir}/src {toxinidir}/setup.py []
61+
pre-commit run --all-files --show-diff-on-failure
6562

6663
[testenv:coverage]
6764
basepython = python3
6865
allowlist_externals =
6966
mkdir
7067
deps =
71-
coverage
68+
coverage[toml]
7269
pypy3: cffi
7370
commands =
7471
mkdir -p {toxinidir}/parts/htmlcov
7572
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
76-
coverage html --ignore-errors
77-
coverage report --ignore-errors --show-missing --fail-under=99
78-
79-
[coverage:run]
80-
branch = True
81-
source = z3c.macro
82-
83-
[coverage:report]
84-
precision = 2
85-
exclude_lines =
86-
pragma: no cover
87-
pragma: nocover
88-
except ImportError:
89-
raise NotImplementedError
90-
if __name__ == '__main__':
91-
self.fail
92-
raise AssertionError
93-
94-
[coverage:html]
95-
directory = parts/htmlcov
73+
coverage html
74+
coverage report

0 commit comments

Comments
 (0)