Skip to content

Commit

Permalink
Config with pure python template (#7)
Browse files Browse the repository at this point in the history
* Drop support for Python 2.7, 3.5, 3.6.
* Add support for Python 3.11.
  • Loading branch information
Michael Howitz committed Jan 12, 2023
1 parent 5ae3a87 commit fdea205
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 60 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,29 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu
- ["ubuntu", "ubuntu-20.04"]
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["pypy-2.7", "pypy"]
- ["3.11", "py311"]
- ["pypy-3.7", "pypy3"]
- ["3.9", "coverage"]

runs-on: ${{ matrix.os }}-latest
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@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config[0] }}
- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
Expand All @@ -58,7 +55,7 @@ jobs:
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "ae61f414cfef4e129d275679c6a76dc67b1a2c11"
commit-id = "4f0f7596"

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

[tox]
use-flake8 = true
Expand Down
8 changes: 6 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
Changes
=======

2.1.1 (unreleased)
==================
3.0 (unreleased)
================

- Add support for Python 3.11.

- Drop support for Python 2.7, 3.5, 3.6.

- Add support for Python 3.9, 3.10.

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 1
universal = 0

[flake8]
doctests = 1
Expand Down
16 changes: 3 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read(*rnames):
return f.read()


version = '2.1.1.dev0'
version = '3.0.dev0'


tests_require = [
Expand All @@ -48,14 +48,7 @@ def read(*rnames):
package_dir={'': 'src'},
namespace_packages=['zope'],
include_package_data=True,
python_requires=', '.join([
'>=2.7',
'!=3.0.*',
'!=3.1.*',
'!=3.2.*',
'!=3.3.*',
'!=3.4.*',
]),
python_requires='>=3.7',
install_requires=[
'BTrees',
'persistent',
Expand Down Expand Up @@ -89,15 +82,12 @@ def read(*rnames):
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'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 :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
Expand Down
6 changes: 3 additions & 3 deletions src/zope/locking/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@component.adapter(interface.Interface)
@interface.implementer(interfaces.ITokenBroker)
class TokenBroker(object):
class TokenBroker:

def __init__(self, context):
self.context = self.__parent__ = context
Expand Down Expand Up @@ -76,10 +76,10 @@ def get(self):
def getInteractionPrincipals():
interaction = zope.security.management.queryInteraction()
if interaction is not None:
return set(p.principal.id for p in interaction.participations)
return {p.principal.id for p in interaction.participations}


class TokenHandler(object):
class TokenHandler:
def __init__(self, token):
self.__parent__ = self.token = token

Expand Down
5 changes: 2 additions & 3 deletions src/zope/locking/generations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

@zope.interface.implementer(
zope.generations.interfaces.IInstallableSchemaManager)
class SchemaManager(object):
class SchemaManager:
minimum_generation = 2
generation = 2

Expand All @@ -46,8 +46,7 @@ def get_site_managers(app_root):
def _get_site_managers(sm):
yield sm
for sm in sm.subs:
for _sm in _get_site_managers(sm):
yield _sm
yield from _get_site_managers(sm)
return _get_site_managers(app_root.getSiteManager())


Expand Down
26 changes: 13 additions & 13 deletions src/zope/locking/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class IAbstractToken(interface.Interface):
an iterable with no members. Readonly.""")

started = schema.Datetime(
description=(u"""the date and time, with utc timezone, that the token
description=("""the date and time, with utc timezone, that the token
was registered with the token utility and became effective. Required
after the token has been registered."""),
required=False, readonly=True)
Expand All @@ -99,29 +99,29 @@ class IEndable(interface.Interface):
"""

ended = schema.Datetime(
description=(u"""the date and time, with utc timezone, that the token
description=("""the date and time, with utc timezone, that the token
ended, explicitly or from expiration."""),
required=False, readonly=True)

expiration = schema.Datetime(
description=(
u"""the expiration time, with utc timezone.
"""the expiration time, with utc timezone.
None indicates no expiration.
Readonly (but see extending interfaces).
"""),
required=False)

duration = schema.Timedelta(
description=(
u"""the duration of the token timeout from its start.
"""the duration of the token timeout from its start.
None indicates no expiration.
Readonly (but see extending interfaces).
"""),
required=False)

remaining_duration = schema.Timedelta(
description=(
u"""the remaining effective duration for the token from "now".
"""the remaining effective duration for the token from "now".
None indicates no expiration. If the token has ended, return
a datetime.timedelta of no time.
Readonly (but see extending interfaces).
Expand Down Expand Up @@ -165,7 +165,7 @@ class IEndableToken(IToken, IEndable):

expiration = schema.Datetime(
description=(
u"""the expiration time, with utc timezone.
"""the expiration time, with utc timezone.
None indicates no expiration.
When setting, if token has ended then raise EndedError.
Otherwise call utility.register, fire ExpirationChangedEvent.
Expand All @@ -174,7 +174,7 @@ class IEndableToken(IToken, IEndable):

duration = schema.Timedelta(
description=(
u"""the duration of the token timeout from its start.
"""the duration of the token timeout from its start.
None indicates no expiration.
When setting, if token has ended then raise EndedError.
Otherwise call utility.register, fire ExpirationChangedEvent.
Expand All @@ -183,7 +183,7 @@ class IEndableToken(IToken, IEndable):

remaining_duration = schema.Timedelta(
description=(
u"""the remaining effective duration for the token from "now".
"""the remaining effective duration for the token from "now".
None indicates no expiration. If the token has ended, return
a datetime.timedelta of no time.
When setting, if token has ended then raise EndedError.
Expand Down Expand Up @@ -306,7 +306,7 @@ class ITokenHandler(IAbstractToken, IEndable):

expiration = schema.Datetime(
description=(
u"""the expiration time, with utc timezone.
"""the expiration time, with utc timezone.
None indicates no expiration.
When setting, if token has ended then raise EndedError.
If all of the principals in the current interaction are not owners
Expand All @@ -317,7 +317,7 @@ class ITokenHandler(IAbstractToken, IEndable):

duration = schema.Timedelta(
description=(
u"""the duration of the token timeout from its start.
"""the duration of the token timeout from its start.
None indicates no expiration.
When setting, if token has ended then raise EndedError.
If all of the principals in the current interaction are not owners
Expand All @@ -328,7 +328,7 @@ class ITokenHandler(IAbstractToken, IEndable):

remaining_duration = schema.Timedelta(
description=(
u"""the remaining effective duration for the token from "now".
"""the remaining effective duration for the token from "now".
None indicates no expiration. If the token has ended, return
a datetime.timedelta of no time.
When setting, if token has ended then raise EndedError.
Expand Down Expand Up @@ -425,14 +425,14 @@ class TokenEndedEvent(ObjectEvent):
@interface.implementer(IPrincipalsChangedEvent)
class PrincipalsChangedEvent(ObjectEvent):
def __init__(self, object, old):
super(PrincipalsChangedEvent, self).__init__(object)
super().__init__(object)
self.old = frozenset(old)


@interface.implementer(IExpirationChangedEvent)
class ExpirationChangedEvent(ObjectEvent):
def __init__(self, object, old):
super(ExpirationChangedEvent, self).__init__(object)
super().__init__(object)
self.old = old


Expand Down
4 changes: 2 additions & 2 deletions src/zope/locking/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ class IDemo(zope.interface.Interface):


@zope.interface.implementer(IDemo)
class Demo(object):
class Demo:
pass


@functools.total_ordering
@zope.component.adapter(IDemo)
@zope.interface.implementer(zope.keyreference.interfaces.IKeyReference)
class DemoKeyReference(object):
class DemoKeyReference:
_class_counter = 0

key_type_id = 'zope.locking.testing.DemoKeyReference'
Expand Down
6 changes: 3 additions & 3 deletions src/zope/locking/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __lt__(self, other):
class EndableToken(Token):

def __init__(self, target, duration=None):
super(EndableToken, self).__init__(target)
super().__init__(target)
self._duration = duration

@property
Expand Down Expand Up @@ -212,15 +212,15 @@ class ExclusiveLock(EndableToken):

def __init__(self, target, principal_id, duration=None):
self._principal_ids = frozenset((principal_id,))
super(ExclusiveLock, self).__init__(target, duration)
super().__init__(target, duration)


@interface.implementer(interfaces.ISharedLock)
class SharedLock(EndableToken):

def __init__(self, target, principal_ids, duration=None):
self._principal_ids = frozenset(principal_ids)
super(SharedLock, self).__init__(target, duration)
super().__init__(target, duration)

def add(self, principal_ids):
if self.ended:
Expand Down
12 changes: 4 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
minversion = 3.18
envlist =
lint
py27
py35
py36
py37
py38
py39
py310
pypy
py311
pypy3
coverage

Expand Down Expand Up @@ -40,6 +37,7 @@ deps =

[testenv:isort-apply]
basepython = python3
skip_install = true
commands_pre =
deps =
isort
Expand All @@ -52,16 +50,14 @@ allowlist_externals =
mkdir
deps =
coverage
coverage-python-version
commands =
mkdir -p {toxinidir}/parts/htmlcov
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
coverage html
coverage report -m --fail-under=83
coverage html --ignore-errors
coverage report --ignore-errors --show-missing --fail-under=83

[coverage:run]
branch = True
plugins = coverage_python_version
source = zope.locking

[coverage:report]
Expand Down

0 comments on commit fdea205

Please sign in to comment.