Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring for pure-python #77

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
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
32 changes: 19 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,32 @@ jobs:
fail-fast: false
matrix:
os:
- ["ubuntu", "ubuntu-20.04"]
- ["ubuntu", "ubuntu-latest"]
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["3.7", "py37"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["pypy-3.9", "pypy3"]
- ["3.9", "docs"]
- ["3.9", "coverage"]
- ["3.11", "release-check"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.12", "py312"]
- ["3.13", "py313"]
- ["pypy-3.10", "pypy3"]
- ["3.11", "docs"]
- ["3.11", "coverage"]

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@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config[0] }}
allow-prereleases: true
- name: Pip cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }}
Expand All @@ -52,7 +54,11 @@ jobs:
python -m pip install --upgrade pip
pip install tox
- name: Test
if: ${{ !startsWith(runner.os, 'Mac') }}
run: tox -e ${{ matrix.config[1] }}
- name: Test (macOS)
if: ${{ startsWith(runner.os, 'Mac') }}
run: tox -e ${{ matrix.config[1] }}-universal2
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
Expand Down
7 changes: 3 additions & 4 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[meta]
template = "pure-python"
commit-id = "b21fbbf2"
commit-id = "fd6b76c6"

[python]
with-pypy = true
Expand All @@ -16,9 +16,8 @@ with-macos = false
fail-under = 90

[tox]
testenv-additional = [
"setenv =",
" ZOPE_INTERFACE_STRICT_IRO=1",
testenv-setenv = [
"ZOPE_INTERFACE_STRICT_IRO=1",
]
use-flake8 = true

Expand Down
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
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
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
7.1 (unreleased)
================

- Drop support for Python 3.7.

- Add support for Python 3.12.

- Fix test suite to use proper line endings (\r\n) in raw multipart/form-data
HTTP requests, because multipart 1.0.0 is stricter about line endings.
Fixes `issue <https://github.com/zopefoundation/zope.publisher/issues/74>`_.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include *.rst
include *.txt
include buildout.cfg
include tox.ini
include .pre-commit-config.yaml

recursive-include docs *.py
recursive-include docs *.rst
Expand Down
57 changes: 31 additions & 26 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# zope.app.apidoc documentation build configuration file, created by
# sphinx-quickstart on Tue Sep 13 15:00:43 2016.
Expand All @@ -21,7 +20,10 @@
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys

import pkg_resources


sys.path.append(os.path.abspath('../src'))
rqmt = pkg_resources.require('zope.publisher')[0]

Expand Down Expand Up @@ -59,9 +61,9 @@
master_doc = 'index'

# General information about the project.
project = u'zope.publisher'
copyright = u'2017, Zope Community'
author = u'Zope Community'
project = 'zope.publisher'
copyright = '2017, Zope Community'
author = 'Zope Community'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -156,8 +158,8 @@
# html_logo = None

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# the docs. This file should be a Windows icon file (.ico) being 16x16 or
# 32x32 pixels large.
#
# html_favicon = None

Expand Down Expand Up @@ -249,29 +251,29 @@
# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'zopepublisher.tex', u'zope.publisher Documentation',
u'Zope Community', 'manual'),
(master_doc, 'zopepublisher.tex', 'zope.publisher Documentation',
'Zope Community', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -312,7 +314,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'zopepublisher', u'zope.publisher Documentation',
(master_doc, 'zopepublisher', 'zope.publisher Documentation',
[author], 1)
]

Expand All @@ -327,7 +329,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'zopepublisher', u'zope.publisher Documentation',
(master_doc, 'zopepublisher', 'zope.publisher Documentation',
author, 'zopepublisher', 'One line description of project.',
'Miscellaneous'),
]
Expand Down Expand Up @@ -360,10 +362,13 @@
'https://zopesite.readthedocs.io/en/latest/': None,
}

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

autodoc_default_flags = ['members', 'show-inheritance']
autoclass_content = 'both'
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python

[build-system]
requires = ["setuptools<74"]
build-backend = "setuptools.build_meta"

[tool.coverage.run]
branch = true
source = ["zope.publisher"]

[tool.coverage.report]
fail_under = 90
precision = 2
ignore_errors = true
show_missing = true
exclude_lines = ["pragma: no cover", "pragma: nocover", "except ImportError:", "raise NotImplementedError", "if __name__ == '__main__':", "self.fail", "raise AssertionError", "raise unittest.Skip"]

[tool.coverage.html]
directory = "parts/htmlcov"
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
[bdist_wheel]
universal = 0

[flake8]
doctests = 1
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ 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',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
Expand Down Expand Up @@ -95,5 +95,5 @@ def read(*rnames):
entry_points=entry_points,
include_package_data=True,
zip_safe=False,
python_requires='>=3.7',
python_requires='>=3.8',
)
30 changes: 15 additions & 15 deletions src/zope/publisher/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ def field2boolean(v):


type_converters = {
'float': field2float,
'int': field2int,
'long': field2long,
'string': field2string,
'float': field2float,
'int': field2int,
'long': field2long,
'string': field2string,
'required': field2required,
'tokens': field2tokens,
'lines': field2lines,
'text': field2text,
'boolean': field2boolean,
'tokens': field2tokens,
'lines': field2lines,
'text': field2text,
'boolean': field2boolean,
}

get_converter = type_converters.get
Expand Down Expand Up @@ -230,7 +230,7 @@ def __repr__(self):
items = list(self.__dict__.items())
items.sort()
return ("{"
+ ", ".join(["{}: {!r}".format(key, value)
+ ", ".join([f"{key}: {value!r}"
for key, value in items]) + "}")


Expand Down Expand Up @@ -689,7 +689,7 @@ def __init__(self, aFieldStorage):
if isinstance(filename, bytes):
filename = filename.decode('UTF-8')
# fix for IE full paths
filename = filename[filename.rfind('\\')+1:].strip()
filename = filename[filename.rfind('\\') + 1:].strip()
self.filename = filename

def release(self):
Expand All @@ -711,10 +711,10 @@ def __init__(self, body_instream=None, environ=None, form=None,
skin=None, **kw):

_testEnv = {
'SERVER_URL': 'http://127.0.0.1',
'HTTP_HOST': '127.0.0.1',
'CONTENT_LENGTH': '0',
'GATEWAY_INTERFACE': 'TestFooInterface/1.0',
'SERVER_URL': 'http://127.0.0.1',
'HTTP_HOST': '127.0.0.1',
'CONTENT_LENGTH': '0',
'GATEWAY_INTERFACE': 'TestFooInterface/1.0',
}

if environ is not None:
Expand Down Expand Up @@ -846,7 +846,7 @@ def isHTML(str):
return True
if s.startswith('<!--'):
idx = s.find('<html')
return idx > 0 and (s[idx+5:idx+6] in ' >')
return idx > 0 and (s[idx + 5:idx + 6] in ' >')
else:
return False

Expand Down
Loading