From 924b27775b1d90c7dcc6a389a6d34bf611c27afa Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Tue, 27 Aug 2024 17:22:56 +0200 Subject: [PATCH 1/3] - update to latest meta/config templates and drop Python 3.7. --- .github/workflows/pre-commit.yml | 33 ++++ .github/workflows/tests.yml | 115 ++------------ .manylinux-install.sh | 2 - .meta.toml | 3 +- .pre-commit-config.yaml | 28 ++++ CHANGES.rst | 4 +- MANIFEST.in | 1 + README.rst | 3 - docs/conf.py | 247 ++--------------------------- setup.py | 12 +- src/zope/proxy/__init__.py | 4 +- src/zope/proxy/tests/test_proxy.py | 112 ++++++------- tox.ini | 18 +-- 13 files changed, 166 insertions(+), 416 deletions(-) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..325ae0e --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,33 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code +name: pre-commit + +on: + pull_request: + push: + branches: + - master + # Allow to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + FORCE_COLOR: 1 + +jobs: + pre-commit: + name: linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --show-diff-on-failure + env: + PRE_COMMIT_COLOR: always + - uses: pre-commit-ci/lite-action@v1.0.2 + if: always() + with: + msg: Apply pre-commit code formatting diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4a4a176..b1200d4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ # Original comment follows. ### ### -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# This workflow will install Python dependencies, run tests with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions ### @@ -81,7 +81,7 @@ jobs: # other people to test/debug), the strategy is to divide the process # into several different jobs. The first builds and saves the binary # wheels. It has dependent jobs that download and install the wheel - # to run tests, build docs, and perform linting. Building the + # to run tests, and build docs. Building the # manylinux wheels is an independent set of jobs. # # This division is time-saving for projects that take awhile to @@ -97,7 +97,6 @@ jobs: matrix: python-version: - "pypy-3.10" - - "3.7" - "3.8" - "3.9" - "3.10" @@ -106,13 +105,8 @@ jobs: - "3.13" os: [ubuntu-latest, macos-latest, windows-latest] exclude: - - os: macos-latest - python-version: "3.7" - os: macos-latest python-version: "pypy-3.10" - include: - - python-version: "3.7" - os: macos-12 steps: - name: checkout @@ -169,11 +163,10 @@ jobs: pip install -U pip pip install -U "setuptools<69" wheel twine - - name: Build zope.proxy (macOS x86_64, Python 3.8+) + - name: Build zope.proxy (macOS x86_64) if: > startsWith(runner.os, 'Mac') - && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7') + && !startsWith(matrix.python-version, 'pypy') env: MACOSX_DEPLOYMENT_TARGET: 10.9 _PYTHON_HOST_PLATFORM: macosx-10.9-x86_64 @@ -183,11 +176,10 @@ jobs: # output (pip install uses a random temporary directory, making this difficult). python setup.py build_ext -i python setup.py bdist_wheel - - name: Build zope.proxy (macOS arm64, Python 3.8+) + - name: Build zope.proxy (macOS arm64) if: > startsWith(runner.os, 'Mac') - && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7') + && !startsWith(matrix.python-version, 'pypy') env: MACOSX_DEPLOYMENT_TARGET: 11.0 _PYTHON_HOST_PLATFORM: macosx-11.0-arm64 @@ -201,7 +193,6 @@ jobs: if: > !startsWith(runner.os, 'Mac') || startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7' run: | # Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure # output (pip install uses a random temporary directory, making this difficult). @@ -230,19 +221,18 @@ jobs: startsWith(runner.os, 'Mac') uses: actions/upload-artifact@v4 with: - name: zope.proxy-${{ runner.os }}-${{ matrix.python-version }}.whl + # The x86_64 wheel is uploaded with a different name just so it can be + # manually downloaded when desired. The wheel itself *cannot* be tested + # on the GHA runner, which uses arm64 architecture. + name: zope.proxy-${{ runner.os }}-${{ matrix.python-version }}-x86_64.whl path: dist/*x86_64.whl - name: Upload zope.proxy wheel (macOS arm64) if: > startsWith(runner.os, 'Mac') - && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7') + && !startsWith(matrix.python-version, 'pypy') uses: actions/upload-artifact@v4 with: - # The arm64 wheel is uploaded with a different name just so it can be - # manually downloaded when desired. The wheel itself *cannot* be tested - # on the GHA runner, which uses x86_64 architecture. - name: zope.proxy-${{ runner.os }}-${{ matrix.python-version }}-arm64.whl + name: zope.proxy-${{ runner.os }}-${{ matrix.python-version }}.whl path: dist/*arm64.whl - name: Upload zope.proxy wheel (all other platforms) if: > @@ -274,7 +264,6 @@ jobs: matrix: python-version: - "pypy-3.10" - - "3.7" - "3.8" - "3.9" - "3.10" @@ -283,13 +272,8 @@ jobs: - "3.13" os: [ubuntu-latest, macos-latest, windows-latest] exclude: - - os: macos-latest - python-version: "3.7" - os: macos-latest python-version: "pypy-3.10" - include: - - python-version: "3.7" - os: macos-12 steps: - name: checkout @@ -340,7 +324,7 @@ jobs: with: name: zope.proxy-${{ runner.os }}-${{ matrix.python-version }}.whl path: dist/ - - name: Install zope.proxy 3.13 ${{ matrix.python-version }} + - name: Install zope.proxy ${{ matrix.python-version }} if: matrix.python-version == '3.13' run: | pip install -U wheel "setuptools<69" @@ -400,7 +384,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.9"] + python-version: ["3.11"] os: [ubuntu-latest] steps: @@ -464,80 +448,13 @@ jobs: sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest - lint: - needs: build-package - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ["3.9"] - os: [ubuntu-latest] - - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - ### - # Caching. - # This actually *restores* a cache and schedules a cleanup action - # to save the cache. So it must come before the thing we want to use - # the cache. - ### - - name: Get pip cache dir (default) - id: pip-cache-default - if: ${{ !startsWith(runner.os, 'Windows') }} - run: | - echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - - name: Get pip cache dir (Windows) - id: pip-cache-windows - if: ${{ startsWith(runner.os, 'Windows') }} - run: | - echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT - - - name: pip cache (default) - uses: actions/cache@v4 - if: ${{ !startsWith(runner.os, 'Windows') }} - with: - path: ${{ steps.pip-cache-default.outputs.dir }} - key: ${{ runner.os }}-pip-${{ matrix.python-version }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: pip cache (Windows) - uses: actions/cache@v4 - if: ${{ startsWith(runner.os, 'Windows') }} - with: - path: ${{ steps.pip-cache-windows.outputs.dir }} - key: ${{ runner.os }}-pip-${{ matrix.python-version }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Download zope.proxy wheel - uses: actions/download-artifact@v4 - with: - name: zope.proxy-${{ runner.os }}-${{ matrix.python-version }}.whl - path: dist/ - - name: Install zope.proxy - run: | - pip install -U pip - pip install -U wheel - pip install -U `ls dist/zope.proxy-*`[test] - - name: Lint - run: | - pip install -U tox - tox -e lint - manylinux: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name # We use a regular Python matrix entry to share as much code as possible. strategy: matrix: - python-version: ["3.9"] + python-version: ["3.11"] image: [manylinux2014_x86_64, manylinux2014_i686, manylinux2014_aarch64] steps: @@ -618,6 +535,8 @@ jobs: name: manylinux_${{ matrix.image }}_wheels.zip - name: Restore pip cache permissions run: sudo chown -R $(whoami) ${{ steps.pip-cache-default.outputs.dir }} + - name: Prevent publishing wheels for unreleased Python versions + run: VER=$(echo '3.13' | tr -d .) && ls -al wheelhouse && sudo rm -f wheelhouse/*-cp${VER}*.whl && ls -al wheelhouse - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 if: > diff --git a/.manylinux-install.sh b/.manylinux-install.sh index 035cf0b..1f95709 100755 --- a/.manylinux-install.sh +++ b/.manylinux-install.sh @@ -29,7 +29,6 @@ yum -y install libffi-devel tox_env_map() { case $1 in *"cp313"*) echo 'py313';; - *"cp37"*) echo 'py37';; *"cp38"*) echo 'py38';; *"cp39"*) echo 'py39';; *"cp310"*) echo 'py310';; @@ -45,7 +44,6 @@ for PYBIN in /opt/python/*/bin; do [[ "${PYBIN}" == *"cp313/"* ]] || \ [[ "${PYBIN}" == *"cp311/"* ]] || \ [[ "${PYBIN}" == *"cp312/"* ]] || \ - [[ "${PYBIN}" == *"cp37/"* ]] || \ [[ "${PYBIN}" == *"cp38/"* ]] || \ [[ "${PYBIN}" == *"cp39/"* ]] || \ [[ "${PYBIN}" == *"cp310/"* ]] ; then diff --git a/.meta.toml b/.meta.toml index 7765302..fd19119 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,10 +2,9 @@ # https://github.com/zopefoundation/meta/tree/master/config/c-code [meta] template = "c-code" -commit-id = "1c0f31f5" +commit-id = "4eec7859" [python] -with-appveyor = false with-windows = true with-pypy = true with-future-python = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b5d6386 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code +minimum_pre_commit_version: '3.6' +repos: + - repo: https://github.com/pycqa/isort + rev: "5.13.2" + hooks: + - id: isort + - repo: https://github.com/hhatto/autopep8 + rev: "v2.3.1" + hooks: + - id: autopep8 + args: [--in-place, --aggressive, --aggressive] + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + - repo: https://github.com/isidentical/teyit + rev: 0.4.3 + hooks: + - id: teyit + - repo: https://github.com/PyCQA/flake8 + rev: "7.1.1" + hooks: + - id: flake8 + additional_dependencies: + - flake8-debugger == 4.1.2 diff --git a/CHANGES.rst b/CHANGES.rst index e1126d3..b766204 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,10 +2,10 @@ Changes ========= -5.4 (unreleased) +6.0 (unreleased) ================ -- Nothing changed yet. +- Drop support for Python 3.7. 5.3 (2024-08-07) diff --git a/MANIFEST.in b/MANIFEST.in index e6615af..da27953 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,7 @@ include *.rst include *.txt include buildout.cfg include tox.ini +include .pre-commit-config.yaml include .coveragerc recursive-include docs *.py diff --git a/README.rst b/README.rst index 67d0266..8003599 100644 --- a/README.rst +++ b/README.rst @@ -5,9 +5,6 @@ .. image:: https://github.com/zopefoundation/zope.proxy/actions/workflows/tests.yml/badge.svg :target: https://github.com/zopefoundation/zope.proxy/actions/workflows/tests.yml -.. image:: https://ci.appveyor.com/api/projects/status/github/zopefoundation/zope.proxy?branch=master&svg=true - :target: https://ci.appveyor.com/project/mgedmin/zope-proxy - .. image:: https://coveralls.io/repos/github/zopefoundation/zope.proxy/badge.svg?branch=master :target: https://coveralls.io/github/zopefoundation/zope.proxy?branch=master diff --git a/docs/conf.py b/docs/conf.py index 4674c09..d54a661 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,249 +1,34 @@ -# -*- coding: utf-8 -*- +# Configuration file for the Sphinx documentation builder. # -# zope.proxy documentation build configuration file, created by -# sphinx-quickstart on Mon Jun 4 15:12:17 2012. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +import datetime -import sys, os -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +year = datetime.datetime.now().year -# -- General configuration ----------------------------------------------------- +project = 'zope.proxy' +copyright = f'2012-{year}, Zope Foundation and contributors' +author = 'Zope Foundation and contributors' -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', - 'sphinx.ext.todo', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', 'repoze.sphinx.autointerface', ] -# Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] +exclude_patterns = [] -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'zope.proxy' -copyright = u'2012, Zope Foundation Contributors' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '4.0' -# The full version, including alpha/beta/rc tags. -release = '4.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. html_theme = 'sphinx_rtd_theme' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'zopeproxydoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'zopeproxy.tex', u'zope.proxy Documentation', - u'Zope Foundation Contributors', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'zopeproxy', u'zope.proxy Documentation', - [u'Zope Foundation Contributors'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'zopeproxy', u'zope.proxy Documentation', - u'Zope Foundation Contributors', 'zopeproxy', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' diff --git a/setup.py b/setup.py index 22b930d..d9a8408 100644 --- a/setup.py +++ b/setup.py @@ -79,7 +79,7 @@ def read(*rnames): headers = [os.path.join('src', 'zope', 'proxy', 'proxy.h')] setup(name='zope.proxy', - version='5.4.dev0', + version='6.0.dev0', author='Zope Foundation and Contributors', author_email='zope-dev@zope.org', description='Generic Transparent Proxies', @@ -90,9 +90,10 @@ def read(*rnames): ), url='http://github.com/zopefoundation/zope.proxy', project_urls={ - 'Documentation': 'https://zopeproxy.readthedocs.io', - 'Issue Tracker': 'https://github.com/zopefoundation/zope.proxy/issues', - 'Sources': 'https://github.com/zopefoundation/zope.proxy', + 'Documentation': 'https://zopeproxy.readthedocs.io', + 'Issue Tracker': 'https://github.com/zopefoundation/' + 'zope.proxy/issues', + 'Sources': 'https://github.com/zopefoundation/zope.proxy', }, license='ZPL 2.1', classifiers=[ @@ -101,7 +102,6 @@ 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', @@ -122,7 +122,7 @@ def read(*rnames): }, headers=headers, ext_modules=ext_modules, - python_requires='>=3.7', + python_requires='>=3.8', install_requires=[ 'zope.interface', 'setuptools', diff --git a/src/zope/proxy/__init__.py b/src/zope/proxy/__init__.py index b2366ab..f22d7f1 100644 --- a/src/zope/proxy/__init__.py +++ b/src/zope/proxy/__init__.py @@ -107,7 +107,7 @@ class AbstractPyProxyBase: def __new__(cls, value=None): # Some subclasses (zope.security.proxy) fail to pass the object - inst = super(AbstractPyProxyBase, cls).__new__(cls) + inst = super().__new__(cls) inst._wrapped = value return inst @@ -197,7 +197,7 @@ def __getattr__(self, name): def __setattr__(self, name, value): if name == '_wrapped': - return super(AbstractPyProxyBase, self).__setattr__(name, value) + return super().__setattr__(name, value) # First, look for descriptors in this object's type type_self = type(self) diff --git a/src/zope/proxy/tests/test_proxy.py b/src/zope/proxy/tests/test_proxy.py index 58649b7..68d2e50 100644 --- a/src/zope/proxy/tests/test_proxy.py +++ b/src/zope/proxy/tests/test_proxy.py @@ -161,16 +161,16 @@ def test___eq___and___ne__(self): w2 = self._makeOne(o2) w3 = self._makeOne(o3) - self.assertTrue(o1 == w1) - self.assertTrue(o1 == w2) - self.assertTrue(o2 == w1) - self.assertTrue(w1 == o2) - self.assertTrue(w2 == o1) + self.assertEqual(o1, w1) + self.assertEqual(o1, w2) + self.assertEqual(o2, w1) + self.assertEqual(w1, o2) + self.assertEqual(w2, o1) - self.assertTrue(o3 != w1) - self.assertTrue(w1 != o3) - self.assertTrue(w3 != o1) - self.assertTrue(o1 != w3) + self.assertNotEqual(o3, w1) + self.assertNotEqual(w1, o3) + self.assertNotEqual(w3, o1) + self.assertNotEqual(o1, w3) def test___lt___and___le__(self): o1 = Comparable(1) @@ -179,12 +179,12 @@ def test___lt___and___le__(self): w1 = self._makeOne(o1) w2 = self._makeOne(o2) - self.assertTrue(w1 < w2) - self.assertTrue(w1 <= w2) - self.assertTrue(o1 < w2) - self.assertTrue(o1 <= w2) - self.assertTrue(w1 < o2) - self.assertTrue(w2 <= o2) + self.assertLess(w1, w2) + self.assertLessEqual(w1, w2) + self.assertLess(o1, w2) + self.assertLessEqual(o1, w2) + self.assertLess(w1, o2) + self.assertLessEqual(w2, o2) def test___gt___and___ge__(self): o1 = Comparable(1) @@ -193,12 +193,12 @@ def test___gt___and___ge__(self): w1 = self._makeOne(o1) w2 = self._makeOne(o2) - self.assertTrue(w2 > w1) - self.assertTrue(w2 >= w1) - self.assertTrue(w2 > o1) - self.assertTrue(w2 >= o1) - self.assertTrue(o2 > w1) - self.assertTrue(o2 >= w2) + self.assertGreater(w2, w1) + self.assertGreaterEqual(w2, w1) + self.assertGreater(w2, o1) + self.assertGreaterEqual(w2, o1) + self.assertGreater(o2, w1) + self.assertGreaterEqual(o2, w2) def test___bool__(self): w = self._makeOne(None) @@ -280,7 +280,7 @@ class Foo: o.foo = 1 w = self._makeOne(o) del w.foo - self.assertFalse('foo' in o.__dict__) + self.assertNotIn('foo', o.__dict__) def test___len__(self): l_ = [] @@ -462,7 +462,7 @@ def __next__(self): myIter = MyIter() p = self._makeOne(myIter) self.assertEqual(iter(p), p) - self.assertTrue(isinstance(iter(p), MyIter)) + self.assertIsInstance(iter(p), MyIter) def test___iter___next_when_returned_by_iterable(self): # Wrap an iterator within the iteration protocol, expecting it @@ -490,8 +490,8 @@ def __iter__(self): def test___contains__(self): w = self._makeOne([0, 1, 2, 3]) - self.assertTrue(1 in w) - self.assertFalse(4 in w) + self.assertIn(1, w) + self.assertNotIn(4, w) def test___index__(self): import operator @@ -560,7 +560,7 @@ def test_inplace(self): a = [1, 2, 3] pa = qa = self._makeOne(a) pa += [4, 5, 6] - self.assertTrue(pa is qa) + self.assertIs(pa, qa) self.assertEqual(a, [1, 2, 3, 4, 5, 6]) pa = self._makeOne(2) @@ -596,7 +596,7 @@ def test_inplace(self): def test___class__(self): o = object() w = self._makeOne(o) - self.assertTrue(w.__class__ is o.__class__) + self.assertIs(w.__class__, o.__class__) def test_descriptor__set___only_in_proxy_subclass(self): @@ -679,8 +679,8 @@ class IFoo(Interface): classImplements(builtin_type, IFoo) builtin = builtin_type() - self.assertTrue(IFoo in list(providedBy(builtin))) - self.assertTrue(IFoo in list(implementedBy(builtin_type))) + self.assertIn(IFoo, list(providedBy(builtin))) + self.assertIn(IFoo, list(implementedBy(builtin_type))) try: # The asserts must be before we remove the interface @@ -688,7 +688,7 @@ class IFoo(Interface): proxy_instance = proxy_class(builtin) provided_instance = providedBy(proxy_instance) - self.assertTrue(IFoo in list(provided_instance)) + self.assertIn(IFoo, list(provided_instance)) proxy_type = proxy_class(builtin_type) from zope.interface.declarations import \ @@ -698,7 +698,7 @@ class IFoo(Interface): BuiltinImplementationSpecifications.get(proxy_type, self), self) provided_type = implementedBy(proxy_type) - self.assertTrue(IFoo in list(provided_type)) + self.assertIn(IFoo, list(provided_type)) finally: classImplementsOnly(builtin_type, *impl_before) @@ -717,7 +717,7 @@ class Proxy(self._getTargetClass()): # the pure-python version if hasattr(Proxy, '__implemented__'): # pragma: no cover from zope.proxy import PyProxyBase - self.assertTrue(self._getTargetClass() is PyProxyBase) + self.assertIs(self._getTargetClass(), PyProxyBase) def test_wrapping_builtin_with_subclass_returns_correct_provided_by(self): self._check_wrapping_builtin_with_subclass_returns_correct_provided_by( @@ -871,14 +871,14 @@ def test_no_proxy(self): class C: pass c = C() - self.assertTrue(self._callFUT(c) is c) + self.assertIs(self._callFUT(c), c) def test_simple_proxy(self): class C: pass c = C() proxy = self._makeProxy(c) - self.assertTrue(self._callFUT(proxy) is c) + self.assertIs(self._callFUT(proxy), c) def test_nested_proxy(self): class C: @@ -886,7 +886,7 @@ class C: c = C() proxy = self._makeProxy(c) proxy2 = self._makeProxy(proxy) - self.assertTrue(self._callFUT(proxy2) is proxy) + self.assertIs(self._callFUT(proxy2), proxy) class Test_getProxiedObject(Test_py_getProxiedObject): @@ -926,7 +926,7 @@ def __init__(self, name): proxy = self._makeProxy(c1) self.assertEqual(proxy.name, 'c1') old = self._callFUT(proxy, c2) - self.assertTrue(old is c1) + self.assertIs(old, c1) self.assertEqual(proxy.name, 'c2') def test_w_nested_proxy(self): @@ -940,7 +940,7 @@ def __init__(self, name): proxy = self._makeProxy(p1) self.assertEqual(proxy.name, 'c1') old = self._callFUT(proxy, proxy2) - self.assertTrue(old is p1) + self.assertIs(old, p1) self.assertEqual(proxy.name, 'c2') @@ -1155,7 +1155,7 @@ class C: pass c = C() p1 = P1(c) - self.assertTrue(self._callFUT(p1) is p1) + self.assertIs(self._callFUT(p1), p1) def test_proxy_w_same_class(self): class P1(self._proxyClass()): @@ -1165,8 +1165,8 @@ class C: pass c = C() p1 = P1(c) - self.assertTrue(self._callFUT(p1, P1) is p1) - self.assertTrue(self._callFUT(p1, P1, 42) is p1) + self.assertIs(self._callFUT(p1, P1), p1) + self.assertIs(self._callFUT(p1, P1, 42), p1) def test_proxy_w_other_class(self): class P1(self._proxyClass()): @@ -1193,8 +1193,8 @@ class C: pass c = C() p1 = P1(c) - self.assertTrue(self._callFUT(p1, self._proxyClass()) is p1) - self.assertTrue(self._callFUT(p1, self._proxyClass(), 42) is p1) + self.assertIs(self._callFUT(p1, self._proxyClass()), p1) + self.assertIs(self._callFUT(p1, self._proxyClass(), 42), p1) class Test_queryProxy(Test_py_queryProxy): @@ -1232,7 +1232,7 @@ class C: pass c = C() p1 = P1(c) - self.assertTrue(self._callFUT(p1) is p1) + self.assertIs(self._callFUT(p1), p1) def test_proxy_w_same_class(self): class P1(self._proxyClass()): @@ -1242,8 +1242,8 @@ class C: pass c = C() p1 = P1(c) - self.assertTrue(self._callFUT(p1, P1) is p1) - self.assertTrue(self._callFUT(p1, P1, 42) is p1) + self.assertIs(self._callFUT(p1, P1), p1) + self.assertIs(self._callFUT(p1, P1, 42), p1) def test_nested_proxy(self): class P1(self._proxyClass()): @@ -1257,10 +1257,10 @@ class C: c = C() p1 = P1(c) proxy2 = P2(p1) - self.assertTrue(self._callFUT(proxy2, P1) is p1) - self.assertTrue(self._callFUT(proxy2, P1, 42) is p1) - self.assertTrue(self._callFUT(proxy2, P2) is proxy2) - self.assertTrue(self._callFUT(proxy2, P2, 42) is proxy2) + self.assertIs(self._callFUT(proxy2, P1), p1) + self.assertIs(self._callFUT(proxy2, P1, 42), p1) + self.assertIs(self._callFUT(proxy2, P2), proxy2) + self.assertIs(self._callFUT(proxy2, P2, 42), proxy2) def test_re_nested_proxy(self): class P1(self._proxyClass()): @@ -1275,10 +1275,10 @@ class C: p1 = P1(c) proxy2 = P2(p1) proxy3 = P1(proxy2) - self.assertTrue(self._callFUT(proxy3, P1) is p1) - self.assertTrue(self._callFUT(proxy3, P1, 42) is p1) - self.assertTrue(self._callFUT(proxy3, P2) is proxy2) - self.assertTrue(self._callFUT(proxy3, P2, 42) is proxy2) + self.assertIs(self._callFUT(proxy3, P1), p1) + self.assertIs(self._callFUT(proxy3, P1, 42), p1) + self.assertIs(self._callFUT(proxy3, P2), proxy2) + self.assertIs(self._callFUT(proxy3, P2, 42), proxy2) class Test_queryInnerProxy(Test_py_queryInnerProxy): @@ -1311,14 +1311,14 @@ def test_no_proxy(self): class C: pass c = C() - self.assertTrue(self._callFUT(c) is c) + self.assertIs(self._callFUT(c), c) def test_simple_proxy(self): class C: pass c = C() proxy = self._makeProxy(c) - self.assertTrue(self._callFUT(proxy) is c) + self.assertIs(self._callFUT(proxy), c) def test_nested_proxy(self): class C: @@ -1326,7 +1326,7 @@ class C: c = C() proxy = self._makeProxy(c) proxy2 = self._makeProxy(proxy) - self.assertTrue(self._callFUT(proxy2) is c) + self.assertIs(self._callFUT(proxy2), c) @unittest.skipUnless(_HAVE_ZOPE_SECURITY, 'zope.security missing') def test_security_proxy(self): diff --git a/tox.ini b/tox.ini index a6ddcf4..ea8349b 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,6 @@ minversion = 4.0 envlist = lint - py37,py37-pure py38,py38-pure py39,py39-pure py310,py310-pure @@ -16,7 +15,6 @@ envlist = coverage [testenv] -usedevelop = true pip_pre = py313: true deps = setuptools < 69 @@ -48,6 +46,7 @@ commands = coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage html -i coverage report -i -m --fail-under=99 + [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 @@ -66,23 +65,14 @@ commands = twine check dist/* [testenv:lint] +description = This env runs all linters configured in .pre-commit-config.yaml basepython = python3 skip_install = true deps = - isort - flake8 -commands = - isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py - flake8 src setup.py - -[testenv:isort-apply] -basepython = python3 -skip_install = true + pre-commit commands_pre = -deps = - isort commands = - isort {toxinidir}/src {toxinidir}/setup.py [] + pre-commit run --all-files --show-diff-on-failure [testenv:docs] basepython = python3 From 36b2dae55878cc9698030af442d6852271a687a4 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Tue, 27 Aug 2024 17:37:30 +0200 Subject: [PATCH 2/3] - fix pyupgrade breakage --- src/zope/proxy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zope/proxy/__init__.py b/src/zope/proxy/__init__.py index f22d7f1..b2366ab 100644 --- a/src/zope/proxy/__init__.py +++ b/src/zope/proxy/__init__.py @@ -107,7 +107,7 @@ class AbstractPyProxyBase: def __new__(cls, value=None): # Some subclasses (zope.security.proxy) fail to pass the object - inst = super().__new__(cls) + inst = super(AbstractPyProxyBase, cls).__new__(cls) inst._wrapped = value return inst @@ -197,7 +197,7 @@ def __getattr__(self, name): def __setattr__(self, name, value): if name == '_wrapped': - return super().__setattr__(name, value) + return super(AbstractPyProxyBase, self).__setattr__(name, value) # First, look for descriptors in this object's type type_self = type(self) From 55eadeeef753153648deba3a03230b8876d3aaf3 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Tue, 27 Aug 2024 17:40:35 +0200 Subject: [PATCH 3/3] - exclude pyupgrade manually to avoid breakage --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b5d6386..3ce9034 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,11 +11,11 @@ repos: hooks: - id: autopep8 args: [--in-place, --aggressive, --aggressive] - - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 - hooks: - - id: pyupgrade - args: [--py38-plus] +# - repo: https://github.com/asottile/pyupgrade +# rev: v3.17.0 +# hooks: +# - id: pyupgrade +# args: [--py38-plus] - repo: https://github.com/isidentical/teyit rev: 0.4.3 hooks: