Skip to content

Commit

Permalink
Config with pure python template (#22)
Browse files Browse the repository at this point in the history
* Drop support for Python 2.7, 3.5, 3.6.
* Update docs config to Sphinx >= 6.
* Add support for Python 3.11.
* Isort imports.
  • Loading branch information
Michael Howitz authored Jan 4, 2023
1 parent d8cef62 commit a4481a3
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 136 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,30 @@ 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", "docs"]
- ["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 +56,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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ lib64
log/
parts/
pyvenv.cfg
testing.log
var/
4 changes: 2 additions & 2 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "863bceecb48a88d769063e4dedce3fd77d2b6187"
commit-id = "3c9d0741"

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

[coverage]
fail-under = 99
Expand Down
8 changes: 5 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
Changes
=========

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

- Add support for Python 3.11.

- Nothing changed yet.
- Drop support for Python 2.7, 3.5, 3.6.


2.1.0 (2022-04-01)
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@
}

extlinks = {'issue': ('https://github.com/zopefoundation/zc.intid/issues/%s',
'issue #'),
'issue %s'),
'pr': ('https://github.com/zopefoundation/zc.intid/pull/%s',
'pull request #')}
'pull request %s')}

autodoc_default_flags = ['members', 'show-inheritance']
autoclass_content = 'both'
Expand Down
13 changes: 12 additions & 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 All @@ -14,3 +14,14 @@ ignore =
.editorconfig
.meta.toml
docs/_build/html/_sources/*

[isort]
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources
known_zope =
known_first_party =
default_section = ZOPE
line_length = 79
lines_after_imports = 2
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
##############################################################################

import os

import setuptools


Expand All @@ -38,7 +39,6 @@ def read(*rnames):
long_description=read("README.rst"),
keywords="zope3 integer id utility",
classifiers=[
# "Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Zope Public License",
Expand All @@ -48,15 +48,12 @@ def read(*rnames):
"Topic :: Internet :: WWW/HTTP",
"Framework :: Zope :: 3",
"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",
],
Expand Down
12 changes: 1 addition & 11 deletions src/zc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
# This is a Python namespace package.

try:
import pkg_resources
except ImportError: # pragma: no cover
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
del pkgutil
else:
pkg_resources.declare_namespace(__name__)
del pkg_resources
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
12 changes: 5 additions & 7 deletions src/zc/intid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
See :mod:`zc.intid.interfaces`.
"""
# BWC imports/re-exports
from zc.intid.interfaces import IIdAddedEvent
from zc.intid.interfaces import IIdEvent
from zc.intid.interfaces import IIdRemovedEvent
from zc.intid.interfaces import IIntIds
from zc.intid.interfaces import IIntIdsManage
from zc.intid.interfaces import IIntIdsQuery
from zc.intid.interfaces import IIntIdsSet
from zc.intid.interfaces import IIntIdsManage
from zc.intid.interfaces import IIntIds

from zc.intid.interfaces import IIntIdsSubclass

from zc.intid.interfaces import IIdEvent
from zc.intid.interfaces import IIdRemovedEvent
from zc.intid.interfaces import IIdAddedEvent
7 changes: 3 additions & 4 deletions src/zc/intid/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"""

import zope.interface

import zope.intid.interfaces


Expand Down Expand Up @@ -199,7 +198,7 @@ class IIdAddedEvent(IIdEvent):
"""


class Event(object):
class Event:

def __init__(self, object, idmanager, id):
self.object = object
Expand Down Expand Up @@ -256,15 +255,15 @@ class IBeforeIdRemovedEvent(ISubscriberEvent):


@zope.interface.implementer(IBeforeIdRemovedEvent)
class BeforeIdRemovedEvent(object):
class BeforeIdRemovedEvent:

def __init__(self, o, event):
self.object = o
self.original_event = event


@zope.interface.implementer(IAfterIdAddedEvent)
class AfterIdAddedEvent(object):
class AfterIdAddedEvent:

def __init__(self, o, event, idmap=None):
self.object = o
Expand Down
18 changes: 5 additions & 13 deletions src/zc/intid/subscribers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A set of subscribers for the object :mod:`zope.lifecycleevent` events.
Expand Down Expand Up @@ -28,27 +27,20 @@
the utility will broadcast its own events. Thus these subscribers
generate at least three events for every lifecycle event.
"""
from __future__ import print_function, absolute_import, division

from zope import component

from zope.component import handle

from zope.lifecycleevent.interfaces import IObjectAddedEvent
from zope.lifecycleevent.interfaces import IObjectRemovedEvent

from zope.location.interfaces import ILocation

from zope.event import notify

from zope.intid.interfaces import IntIdAddedEvent
from zope.intid.interfaces import IntIdRemovedEvent

from zope.keyreference.interfaces import IKeyReference
from zope.lifecycleevent.interfaces import IObjectAddedEvent
from zope.lifecycleevent.interfaces import IObjectRemovedEvent
from zope.location.interfaces import ILocation

from zc.intid.interfaces import IIntIds
from zc.intid.interfaces import BeforeIdRemovedEvent
from zc.intid.interfaces import AfterIdAddedEvent
from zc.intid.interfaces import BeforeIdRemovedEvent
from zc.intid.interfaces import IIntIds


def _utilities_and_key(ob):
Expand Down
56 changes: 25 additions & 31 deletions src/zc/intid/tests/test_subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,49 @@
Tests for the lifecycle subscribers.
"""

from persistent.interfaces import IPersistent
import unittest

import zc.intid

from zc.intid.interfaces import AddedEvent
from zc.intid.interfaces import AfterIdAddedEvent
from zc.intid.interfaces import BeforeIdRemovedEvent
from zc.intid.interfaces import IIdEvent
from zc.intid.interfaces import IIntIds
from zc.intid.interfaces import ISubscriberEvent
from zc.intid.interfaces import RemovedEvent

from zc.intid.subscribers import addIntIdSubscriber
from zc.intid.subscribers import removeIntIdSubscriber

from zc.intid.utility import IntIds

from zope.component import getSiteManager
from persistent.interfaces import IPersistent
from zope.component import eventtesting
from zope.component import getGlobalSiteManager
from zope.component import getSiteManager
from zope.component import handle
from zope.component import provideAdapter
from zope.component import provideHandler
from zope.component import testing as componenttesting
from zope.component import eventtesting
from zope.component.hooks import setSite, setHooks, resetHooks
from zope.component.hooks import resetHooks
from zope.component.hooks import setHooks
from zope.component.hooks import setSite
from zope.component.interfaces import ISite

from zope.configuration import xmlconfig

from zope.interface import Interface
from zope.interface.interfaces import IComponentLookup

from zope.intid.interfaces import IIntIdEvent
from zope.intid.interfaces import IntIdAddedEvent
from zope.intid.interfaces import IntIdRemovedEvent
from zope.intid.interfaces import ObjectMissingError

from zope.keyreference.interfaces import IKeyReference

from zope.lifecycleevent import ObjectAddedEvent
from zope.lifecycleevent import ObjectRemovedEvent

from zope.site.folder import rootFolder, Folder
from zope.site.folder import Folder
from zope.site.folder import rootFolder
from zope.site.interfaces import IFolder
from zope.site.site import SiteManagerAdapter, LocalSiteManager

from zope.site.site import LocalSiteManager
from zope.site.site import SiteManagerAdapter
from zope.traversing.testing import setUp as traversingSetUp

import zc.intid
from zc.intid.interfaces import AddedEvent
from zc.intid.interfaces import AfterIdAddedEvent
from zc.intid.interfaces import BeforeIdRemovedEvent
from zc.intid.interfaces import IIdEvent
from zc.intid.interfaces import IIntIds
from zc.intid.interfaces import ISubscriberEvent
from zc.intid.interfaces import RemovedEvent
from zc.intid.subscribers import addIntIdSubscriber
from zc.intid.subscribers import removeIntIdSubscriber
from zc.intid.utility import IntIds


def createSiteManager(folder, setsite=False):
if not ISite.providedBy(folder):
Expand All @@ -73,13 +67,13 @@ def createSiteManager(folder, setsite=False):
return folder.getSiteManager()


class KeyReferenceStub(object):
class KeyReferenceStub:

def __init__(self, obj):
self.obj = obj


class ReferenceSetupMixin(object):
class ReferenceSetupMixin:
"""Registers adapters ILocation->IConnection and IPersistent->IReference"""

def setUp(self):
Expand Down Expand Up @@ -235,5 +229,5 @@ def test_addIntIdSubscriber(self):

def test_suite():
return unittest.TestSuite([
unittest.makeSuite(TestSubscribers),
unittest.defaultTestLoader.loadTestsFromTestCase(TestSubscribers),
])
Loading

0 comments on commit a4481a3

Please sign in to comment.