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.
  • Loading branch information
Michael Howitz committed Dec 20, 2022
1 parent 058cb9c commit 2b1ade8
Show file tree
Hide file tree
Showing 31 changed files with 181 additions and 142 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,29 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu
- ["ubuntu", "ubuntu-20.04"]
config:
# [Python version, tox env]
- ["3.8", "lint"]
- ["2.7", "py27"]
- ["3.5", "py35"]
- ["3.6", "py36"]
- ["3.9", "lint"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["pypy2", "pypy"]
- ["pypy3", "pypy3"]
- ["3.8", "coverage"]
- ["3.10", "py310"]
- ["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 @@ -56,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 }}
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/
3 changes: 2 additions & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "d3627ba9bcb25d0c7cb09b96d695040a20e0ab2b"
commit-id = "3018c57b"

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

[coverage]
fail-under = 94
Expand Down
8 changes: 6 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Changes
=======

3.2.0 (unreleased)
------------------
4.0 (unreleased)
----------------

* Add support for Python 3.10, 3.11.

* Drop support for Python 2.7, 3.5, 3.6.

- Add support for Python 3.7, 3.8 and 3.9.

Expand Down
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Generated from:
https://github.com/zopefoundation/meta/tree/master/config/pure-python
-->
# Contributing to zopefoundation projects

The projects under the zopefoundation GitHub organization are open source and
welcome contributions in different forms:

* bug reports
* code improvements and bug fixes
* documentation improvements
* pull request reviews

For any changes in the repository besides trivial typo fixes you are required
to sign the contributor agreement. See
https://www.zope.dev/developer/becoming-a-committer.html for details.

Please visit our [Developer
Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to
contribute code changes and our [guidelines for reporting
bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a
bug report.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
include *.md
include *.rst
include *.txt
include buildout.cfg
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 @@ per-file-ignores =
ignore =
.editorconfig
.meta.toml

[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
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from setuptools import setup, find_packages

from setuptools import find_packages
from setuptools import setup


def read(*rnames):
Expand Down Expand Up @@ -29,7 +31,7 @@ def read(*rnames):

setup(
name='grokcore.viewlet',
version='3.2.0.dev0',
version='4.0.dev0',
author='Grok Team',
author_email='grok-dev@zope.org',
url='http://grok.zope.org',
Expand All @@ -42,14 +44,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',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
Expand Down
8 changes: 1 addition & 7 deletions src/grokcore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
11 changes: 6 additions & 5 deletions src/grokcore/viewlet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
from grokcore.component import *
from grokcore.security import *
from grokcore.view import *

from grokcore.viewlet.components import Viewlet, ViewletManager
from grokcore.viewlet.directive import viewletmanager
from zope.interface import moduleProvides

# Import this module so that it's available as soon as you import the
# 'grokcore.view' package. Useful for tests and interpreter examples.
import grokcore.viewlet.testing

from grokcore.viewlet.components import Viewlet
from grokcore.viewlet.components import ViewletManager
from grokcore.viewlet.directive import viewletmanager
# Our __init__ provides the grok API directly so using 'import grok' is enough.
from grokcore.viewlet.interfaces import IGrokcoreViewletAPI
from zope.interface import moduleProvides


moduleProvides(IGrokcoreViewletAPI)
__all__ = list(IGrokcoreViewletAPI)
14 changes: 8 additions & 6 deletions src/grokcore/viewlet/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

from operator import itemgetter

from zope import component, interface
from zope import component
from zope import interface
from zope.viewlet.manager import ViewletManagerBase
from zope.viewlet.viewlet import ViewletBase

from grokcore.viewlet import interfaces, util
from grokcore.viewlet import interfaces
from grokcore.viewlet import util


@interface.implementer(interfaces.IViewletManager)
Expand All @@ -28,7 +30,7 @@ class ViewletManager(ViewletManagerBase):
template = None

def __init__(self, context, request, view):
super(ViewletManager, self).__init__(context, request, view)
super().__init__(context, request, view)
self.context = context
self.request = request
self.view = view
Expand Down Expand Up @@ -63,7 +65,7 @@ def namespace(self):
return {}

def update(self):
super(ViewletManager, self).update()
super().update()
# Filter out the unavailable viewlets *after* the viewlet's update()
# has been called.
self.viewlets = [v for v in self.viewlets if v.available()]
Expand All @@ -74,7 +76,7 @@ def render(self):
if self.template:
return self.template.render(self)
else:
return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
return '\n'.join([viewlet.render() for viewlet in self.viewlets])
# Mark the render() method as a method from the base class. That
# way we can detect whether somebody overrides render() in a subclass.
render.base_method = True
Expand All @@ -85,7 +87,7 @@ class Viewlet(ViewletBase):
"""

def __init__(self, context, request, view, manager):
super(Viewlet, self).__init__(context, request, view, manager)
super().__init__(context, request, view, manager)
self.context = context
self.request = request
self.view = view
Expand Down
3 changes: 2 additions & 1 deletion src/grokcore/viewlet/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"""

import martian
from martian.util import scan_for_classes
from martian.error import GrokError
from martian.util import scan_for_classes

from grokcore.viewlet.interfaces import IViewletManager


Expand Down
5 changes: 2 additions & 3 deletions src/grokcore/viewlet/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
##############################################################################
"""Grok interfaces
"""
from zope import interface
from zope.viewlet.interfaces import IViewletManager as IViewletManagerBase

import grokcore.component.interfaces
import grokcore.security.interfaces
import grokcore.view.interfaces
from zope import interface
from zope.viewlet.interfaces import IViewletManager as IViewletManagerBase


class IBaseClasses(grokcore.component.interfaces.IBaseClasses,
Expand Down
19 changes: 10 additions & 9 deletions src/grokcore/viewlet/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
##############################################################################
"""Grokkers for the various components."""

from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.viewlet.interfaces import IViewletManager, IViewlet

import martian

import grokcore.component
import grokcore.view
from grokcore.view.meta.views import default_view_name, TemplateGrokker
import grokcore.security
import grokcore.view
import martian
from grokcore.view.meta.views import TemplateGrokker
from grokcore.view.meta.views import default_view_name
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.viewlet.interfaces import IViewlet
from zope.viewlet.interfaces import IViewletManager

import grokcore.viewlet
from grokcore.viewlet.util import make_checker

Expand Down Expand Up @@ -50,7 +51,7 @@ def grok(self, name, factory, module_info, **kw):
# Need to store the module info object on the view class so that it
# can look up the 'static' resource directory.
factory.module_info = module_info
return super(ViewletManagerGrokker, self).grok(
return super().grok(
name, factory, module_info, **kw)

def execute(self, factory, config, context, layer, view, name, **kw):
Expand Down Expand Up @@ -89,7 +90,7 @@ def grok(self, name, factory, module_info, **kw):
# Need to store the module info object on the view class so that it
# can look up the 'static' resource directory.
factory.module_info = module_info
return super(ViewletGrokker, self).grok(
return super().grok(
name, factory, module_info, **kw)

def execute(self, factory, config,
Expand Down
3 changes: 2 additions & 1 deletion src/grokcore/viewlet/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"""Grok test helpers
"""
import sys
from zope.configuration.config import ConfigurationMachine

from grokcore.component import zcml
from zope.configuration.config import ConfigurationMachine


def grok(module_name):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
""" # noqa: E501 line too long

import grokcore.viewlet as grok
from zope.interface import Interface

import grokcore.viewlet as grok


class ViewletManager(grok.ViewletManager):
grok.name('foo')
Expand All @@ -29,4 +30,4 @@ class Viewlet(grok.Viewlet):
grok.context(Interface)

def render(self):
return u"Render method"
return "Render method"
6 changes: 3 additions & 3 deletions src/grokcore/viewlet/tests/base/viewlet/viewlet_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ViewWithItems(grok.View):
grok.name('with_items')

def render(self):
return u""
return ""


class ViewItemsManager(grok.ViewletManager):
Expand All @@ -59,11 +59,11 @@ class ItemOneViewlet(grok.Viewlet):
grok.name('item_one')

def render(self):
return u"Item one reporting, sir!"
return "Item one reporting, sir!"


class ItemTwoViewlet(grok.Viewlet):
grok.name('item_two')

def render(self):
return u"Item two reporting, sir!"
return "Item two reporting, sir!"
Loading

0 comments on commit 2b1ade8

Please sign in to comment.