Skip to content

Commit

Permalink
Add support for Python 3.11.
Browse files Browse the repository at this point in the history
* isort imports.
  • Loading branch information
Michael Howitz committed Dec 16, 2022
1 parent 3f1acc7 commit 69811d4
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Expand Up @@ -5,7 +5,7 @@
5.3 (unreleased)
================

- Nothing changed yet.
- Add support for Python 3.11.


5.2 (2022-08-24)
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Expand Up @@ -19,7 +19,9 @@
"""Setup for zope.tales package
"""
import os
from setuptools import setup, find_packages

from setuptools import find_packages
from setuptools import setup


def read(*rnames):
Expand Down Expand Up @@ -61,6 +63,7 @@ def read(*rnames):
'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
8 changes: 4 additions & 4 deletions src/zope/tales/engine.py
Expand Up @@ -15,14 +15,14 @@
Each expression engine can have its own expression types and base names.
"""
from zope.tales.tales import ExpressionEngine
from zope.tales.expressions import PathExpr
from zope.tales.expressions import StringExpr
from zope.tales.expressions import NotExpr
from zope.tales.expressions import DeferExpr
from zope.tales.expressions import LazyExpr
from zope.tales.expressions import NotExpr
from zope.tales.expressions import PathExpr
from zope.tales.expressions import SimpleModuleImporter
from zope.tales.expressions import StringExpr
from zope.tales.pythonexpr import PythonExpr
from zope.tales.tales import ExpressionEngine


def DefaultEngine():
Expand Down
10 changes: 8 additions & 2 deletions src/zope/tales/expressions.py
Expand Up @@ -28,8 +28,14 @@
import six

from zope.interface import implementer
from zope.tales.tales import _valid_name, _parse_expr, NAME_RE, Undefined
from zope.tales.interfaces import ITALESExpression, ITALESFunctionNamespace

from zope.tales.interfaces import ITALESExpression
from zope.tales.interfaces import ITALESFunctionNamespace
from zope.tales.tales import NAME_RE
from zope.tales.tales import Undefined
from zope.tales.tales import _parse_expr
from zope.tales.tales import _valid_name


Undefs = (Undefined, AttributeError, LookupError, TypeError)

Expand Down
1 change: 1 addition & 0 deletions src/zope/tales/interfaces.py
Expand Up @@ -16,6 +16,7 @@
"""
from zope.interface import Interface


try:
from zope.tal.interfaces import ITALIterator
except ImportError:
Expand Down
12 changes: 7 additions & 5 deletions src/zope/tales/tales.py
Expand Up @@ -17,15 +17,17 @@
"""
import re


try:
from html import escape
except ImportError: # pragma: PY2
from cgi import escape

from zope.interface import implementer
from zope.interface import Interface
import six

from zope.interface import Interface
from zope.interface import implementer

from zope.tales.interfaces import ITALESIterator


Expand All @@ -43,9 +45,9 @@ class ITALExpressionErrorInfo(Interface):

try:
# Override with real, if present
from zope.tal.interfaces import (ITALExpressionEngine, # noqa: F811
ITALExpressionCompiler,
ITALExpressionErrorInfo)
from zope.tal.interfaces import ITALExpressionCompiler # noqa: F811
from zope.tal.interfaces import ITALExpressionEngine # noqa: F811
from zope.tal.interfaces import ITALExpressionErrorInfo # noqa: F811
except ImportError:
pass

Expand Down
3 changes: 2 additions & 1 deletion src/zope/tales/tests/__init__.py
@@ -1,6 +1,7 @@
import six
import unittest

import six


class TestCase(unittest.TestCase):
"""Base test case for Python version compatibility."""
Expand Down
16 changes: 10 additions & 6 deletions src/zope/tales/tests/test_expressions.py
Expand Up @@ -14,14 +14,17 @@
##############################################################################
"""Default TALES expression implementations tests.
"""
import six
import unittest

import six

from zope.interface import implementer

import zope.tales.tests
from zope.tales.engine import Engine
from zope.tales.interfaces import ITALESFunctionNamespace
from zope.tales.tales import Undefined
from zope.interface import implementer
import zope.tales.tests


text_type = str if str is not bytes else unicode # noqa PY2

Expand Down Expand Up @@ -341,8 +344,8 @@ def check(expr):
check('string:foo${ab/cd | c/d | e/f/}bar')

def test_defer_expression_returns_wrapper(self):
from zope.tales.expressions import DeferWrapper
from zope.tales.expressions import DeferExpr
from zope.tales.expressions import DeferWrapper
expr = self.engine.compile('defer: B')
self.assertIsInstance(expr, DeferExpr)
self.assertEqual(str(expr), "<DeferExpr 'B'>")
Expand All @@ -361,8 +364,8 @@ def test_eval_defer_wrapper(self):
self._check_evals_to('deferred', self.context.vars['b'])

def test_lazy_expression_returns_wrapper(self):
from zope.tales.expressions import LazyWrapper
from zope.tales.expressions import LazyExpr
from zope.tales.expressions import LazyWrapper
expr = self.engine.compile('lazy: b')
self.assertIsInstance(expr, LazyExpr)
self.assertEqual(repr(expr), "lazy:'b'")
Expand Down Expand Up @@ -393,8 +396,9 @@ def test_bad_initial_name_subexpr(self):
)

def test_builtins_in_path(self):
from ..expressions import PathExpr
from ..expressions import SubPathExpr
from ..tales import ExpressionEngine
from ..expressions import PathExpr, SubPathExpr

class MySubPathExpr(SubPathExpr):
ALLOWED_BUILTINS = {'True': True, 'False': False, 'x': None}
Expand Down
8 changes: 4 additions & 4 deletions src/zope/tales/tests/test_pythonexpr.py
Expand Up @@ -12,14 +12,14 @@
#
##############################################################################

import six
import unittest

from zope.tales.engine import Engine
from zope.tales.tales import Context
import six

from zope.tales.pythonexpr import PythonExpr
from zope.tales.engine import Engine
from zope.tales.pythonexpr import ExprTypeProxy
from zope.tales.pythonexpr import PythonExpr
from zope.tales.tales import Context


class TestPythonExpr(unittest.TestCase):
Expand Down
10 changes: 6 additions & 4 deletions src/zope/tales/tests/test_tales.py
Expand Up @@ -13,16 +13,18 @@
##############################################################################
"""TALES Tests
"""
from doctest import DocTestSuite
import unittest
import re
import sys
import unittest
from doctest import DocTestSuite

import six
from zope.tales import tales
from zope.tales.tests.simpleexpr import SimpleExpr

from zope.testing import renormalizing

import zope.tales.tests
from zope.tales import tales
from zope.tales.tests.simpleexpr import SimpleExpr


class TestIterator(unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions src/zope/tales/tests/test_traverser.py
Expand Up @@ -14,6 +14,7 @@
""" Tests for zope.tales.expressions.simpleTraverse
"""
from unittest import TestCase

from zope.tales.expressions import simpleTraverse


Expand Down

0 comments on commit 69811d4

Please sign in to comment.