Skip to content

Commit

Permalink
Update Python version support. (#122)
Browse files Browse the repository at this point in the history
* Drop support for Python 3.7.
* Add support for Python 3.12.
  • Loading branch information
icemac authored Aug 14, 2024
1 parent 53fcbed commit a3499ff
Show file tree
Hide file tree
Showing 22 changed files with 109 additions and 102 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,30 @@ 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.11", "release-check"]
- ["3.11", "lint"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.9", "docs"]
- ["3.9", "coverage"]
- ["3.12", "py312"]
- ["3.11", "docs"]
- ["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
name: ${{ matrix.config[1] }}
steps:
- 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] }}
- 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 @@ -51,7 +52,11 @@ jobs:
python -m pip install --upgrade pip
pip install tox
- name: Test
if: ${{ !startsWith(runner.os, 'Mac') }}
run: tox -e ${{ 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
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/pure-python
[meta]
template = "pure-python"
commit-id = "b21fbbf2"
commit-id = "994c74d7"

[python]
with-windows = false
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Changelog
5.2 (unreleased)
----------------

- Add support for Python 3.12.

- Drop support for Python 3.7.

- Add basque (eu) translation.

- Fix tests to run with ``lxml >= 5.3``, thus requiring at least that version.
Expand Down
2 changes: 0 additions & 2 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/pure-python
[bdist_wheel]
universal = 0

[flake8]
doctests = 1
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def read(*rnames):
'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 :: Implementation :: CPython',
'Natural Language :: English',
'Operating System :: OS Independent',
Expand All @@ -64,7 +64,7 @@ def read(*rnames):
include_package_data=True,
package_dir={'': 'src'},
namespace_packages=['z3c'],
python_requires='>=3.7',
python_requires='>=3.8',
extras_require=dict(
extra=[
'z3c.pt >= 2.1',
Expand Down
4 changes: 2 additions & 2 deletions src/z3c/form/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, action):
self.action = action

def __repr__(self):
return '<{} for {!r}>'.format(self.__class__.__name__, self.action)
return f'<{self.__class__.__name__} for {self.action!r}>'


@zope.interface.implementer(interfaces.IActionErrorEvent)
Expand Down Expand Up @@ -104,7 +104,7 @@ def execute(self):
return result

def __repr__(self):
return '<{} {!r}>'.format(self.__class__.__name__, self.__name__)
return f'<{self.__class__.__name__} {self.__name__!r}>'


@zope.interface.implementer(interfaces.IActionHandler)
Expand Down
7 changes: 1 addition & 6 deletions src/z3c/form/browser/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id$
"""
__docformat__ = "reStructuredText"

import doctest
import itertools
import unittest
Expand All @@ -28,7 +23,7 @@
try:
import z3c.pt
import z3c.ptcompat # noqa: F401 imported but unused
except ImportError:
except ModuleNotFoundError:
Z3CPT_AVAILABLE = False


Expand Down
55 changes: 23 additions & 32 deletions src/z3c/form/browser/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def addClass(self, klass: str):
# make sure items are not repeated
parts = self.klass.split() + klass.split()
# Remove duplicates and keep order.
# Dictionaries are ordered in Python 3.7+
parts = list(dict.fromkeys(parts))
self.klass = " ".join(parts)

Expand Down Expand Up @@ -224,14 +223,12 @@ class HTMLInputWidget(HTMLFormElement):
@property
def _html_attributes(self) -> list:
attributes = super()._html_attributes
attributes.extend(
[
"readonly",
"alt",
"accesskey",
"onselect",
]
)
attributes.extend([
"readonly",
"alt",
"accesskey",
"onselect",
])
return attributes


Expand All @@ -247,14 +244,12 @@ class HTMLTextInputWidget(HTMLInputWidget):
@property
def _html_attributes(self) -> list:
attributes = super()._html_attributes
attributes.extend(
[
"size",
"maxlength",
"placeholder",
"autocapitalize",
]
)
attributes.extend([
"size",
"maxlength",
"placeholder",
"autocapitalize",
])
return attributes


Expand All @@ -270,15 +265,13 @@ class HTMLTextAreaWidget(HTMLFormElement):
@property
def _html_attributes(self) -> list:
attributes = super()._html_attributes
attributes.extend(
[
"rows",
"cols",
"readonly",
"accesskey",
"onselect",
]
)
attributes.extend([
"rows",
"cols",
"readonly",
"accesskey",
"onselect",
])
return attributes


Expand All @@ -291,12 +284,10 @@ class HTMLSelectWidget(HTMLFormElement):
@property
def _html_attributes(self) -> list:
attributes = super()._html_attributes
attributes.extend(
[
"multiple",
"size",
]
)
attributes.extend([
"multiple",
"size",
])
return attributes


Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __call__(self, form, action):
return self.func(form, action)

def __repr__(self):
return '<{} for {!r}>'.format(self.__class__.__name__, self.button)
return f'<{self.__class__.__name__} for {self.button!r}>'


def handler(button):
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/button.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ First, you are able to add button managers:
>>> bm2 = button.Buttons(button.Button('help', title='Help'))

>>> bm1 + bm2
Buttons([...])
Buttons(...)
>>> list(bm1 + bm2)
['apply', 'cancel', 'help']

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/contentprovider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ To enable form updating, all widget adapters must be registered::

>>> personForm.update()
>>> personForm.widgets
FieldWidgetsAndProviders([...])
FieldWidgetsAndProviders(...)

Let's render the form::

Expand Down
8 changes: 2 additions & 6 deletions src/z3c/form/datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Widget Framework Implementation
$Id$
"""
__docformat__ = "reStructuredText"
"""Widget Framework Implementation."""

import zope.component
import zope.interface
Expand All @@ -35,7 +31,7 @@
try:
import persistent.mapping
ALLOWED_DATA_CLASSES.append(persistent.mapping.PersistentMapping)
except ImportError:
except ModuleNotFoundError:
pass


Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, field, name=None, prefix='', mode=None, interface=None,
self.showDefault = showDefault

def __repr__(self):
return '<{} {!r}>'.format(self.__class__.__name__, self.__name__)
return f'<{self.__class__.__name__} {self.__name__!r}>'


@zope.interface.implementer(interfaces.IFields)
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/field.rst
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ When a widget is added to the widget manager, it is located:
>>> lname.__name__
'lastName'
>>> lname.__parent__
FieldWidgets([...])
FieldWidgets(...)

All widgets created by this widget manager are context aware:

Expand Down
2 changes: 1 addition & 1 deletion src/z3c/form/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ The widget manager is then stored in the ``widgets`` attribute as promised by
the ``IForm`` interface:

>>> addForm.widgets
FieldWidgets([...])
FieldWidgets(...)

The widget manager will have four widgets, one for each field:

Expand Down
Loading

0 comments on commit a3499ff

Please sign in to comment.