Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
run: python -m pip install --upgrade pip tox tox-gh
run: python -m pip install --upgrade pip tox tox-gh
- name: "Run tox targets for ${{ matrix.python-version }}"
run: "python -m tox"

Expand Down
14 changes: 10 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ __pycache__/
pip-wheel-metadata

# Virtualenv
.venv/
/env/
/src/

# Unit test / coverage reports
.cache/
/.coverage
/htmlcov
/.tox
.cache
.pytest_cache
.coverage
htmlcov
.tox

# Sphinx documentation
/doc/build/
/doc/_build/

# Type checkers
.mypy_cache/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
rev: "7.3.0"
hooks:
- id: flake8
additional_dependencies: [flake8-pyproject]
additional_dependencies: [flake8-pyproject, flake8-type-checking]
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ With contributions by
Special contributions
---------------------

* Special thanks to CONTACT software (http://contact.de)
* Special thanks to CONTACT software (https://www.contact-software.com/)

Special inspiration
-------------------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ for your application, library or framework.

Documentation_.

.. _Documentation: http://reg.readthedocs.org
.. _Documentation: https://reg.readthedocs.io
3 changes: 1 addition & 2 deletions develop_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# development
-e '.[test,coverage,lint,docs]'
-e '.[test,coverage,lint,docs,mypy,pyright]'
pre-commit
tox >= 4
radon

# releaser
zest.releaser[recommended]
56 changes: 45 additions & 11 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# serve to show the default.

import os
import pkg_resources
from datetime import datetime
from importlib import metadata

# 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
Expand All @@ -32,6 +32,20 @@
"sphinx.ext.intersphinx",
]

# These are internal typing-only names (TypeVars, ParamSpecs, and type
# aliases/protocols that only exist for static type checkers) that show up
# in autodoc-rendered signatures but are never documented as objects of
# their own, so they can never resolve to a cross-reference target.
nitpick_ignore_regex = [
("py:class", r"^(.*\.)?_(P|T|R|F|ValueT)(\.(args|kwargs))?$"),
("py:class", r"^(.*\.)?(Get)?KeyLookup$"),
]
# inspect.FullArgSpec is a real class, but the CPython docs don't expose
# it as a linkable object (only inspect.getfullargspec is documented).
nitpick_ignore = [
("py:class", "inspect.FullArgSpec"),
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand All @@ -47,17 +61,31 @@
# General information about the project.
project = "Reg"
copyright = "2010 - %s, Morepath Developers" % datetime.today().year
author = "Martijn Faassen"

# 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 = pkg_resources.get_distribution("reg").version
try:
version = metadata.version("reg")
except metadata.PackageNotFoundError:
# Fallback for ReadTheDocs and other environments where the package isn't installed
# Try to get version from pyproject.toml
import re

try:
pyproject_path = os.path.join(os.path.dirname(__file__), "..", "pyproject.toml")
with open(pyproject_path) as f:
content = f.read()
# Simple regex to extract version
version_match = re.search(r'version\s*=\s*["\']([^"\']+)["\']', content)
version = version_match.group(1) if version_match else "0.0.0"
except (FileNotFoundError, Exception):
version = "0.0.0"
# The full version, including alpha/beta/rc tags.
release = version
if release.endswith("dev"):
release = "%s (unreleased)" % release

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -71,7 +99,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["build"]
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
Expand Down Expand Up @@ -127,7 +155,7 @@
# 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 = []
html_static_path: list[str] = []

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down Expand Up @@ -176,7 +204,7 @@

# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
latex_elements: dict[str, str] = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
Expand All @@ -188,7 +216,13 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
("index", "Reg.tex", "Reg Documentation", "Martijn Faassen", "manual"),
(
"index",
"Reg.tex",
"Reg Documentation",
author,
"manual",
),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -216,7 +250,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "reg", "Reg Documentation", ["Martijn Faassen"], 1)]
man_pages = [(master_doc, "reg", "Reg Documentation", [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -232,7 +266,7 @@
"index",
"Reg",
"Reg Documentation",
"Martijn Faassen",
author,
"Reg",
"One line description of project.",
"Miscellaneous",
Expand All @@ -250,4 +284,4 @@

doctest_path = [os.path.abspath("..")]

intersphinx_mapping = {"python": ("http://docs.python.org/3.5", None)}
intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
31 changes: 13 additions & 18 deletions doc/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ Make sure you have virtualenv_ installed.

Create a new virtualenv for Python 3 inside the reg directory::

$ virtualenv -p python3 env/py3
$ python -m venv --upgrade-deps .venv

Activate the virtualenv::

$ source env/py3/bin/activate

Make sure you have recent setuptools and pip installed::

$ pip install -U setuptools pip
$ source .venv/bin/activate

Install the various dependencies and development tools from
develop_requirements.txt::
Expand All @@ -42,9 +38,8 @@ For upgrading the requirements just run the command again.

The following commands work only if you have the virtualenv activated.

.. _github: https://help.github.com/articles/generating-an-ssh-key

.. _virtualenv: https://pypi.python.org/pypi/virtualenv
.. _github: https://docs.github.com/en/authentication/connecting-to-github-with-ssh
.. _virtualenv: https://pypi.org/project/virtualenv

Install pre-commit hook for Black integration
---------------------------------------------
Expand All @@ -54,7 +49,7 @@ install the `pre-commit hook`_ for Black integration before committing::

$ pre-commit install

.. _`pre-commit hook`: https://black.readthedocs.io/en/stable/version_control_integration.html
.. _`pre-commit hook`: https://black.readthedocs.io/en/stable/integrations/source_version_control.html

Running the tests
-----------------
Expand All @@ -71,14 +66,14 @@ You can then point your web browser to the ``htmlcov/index.html`` file
in the project directory and click on modules to see detailed coverage
information.

.. _`py.test`: http://pytest.org/latest/
.. _`py.test`: https://pytest.org/latest/

Black
-----

To format the code with the `Black Code Formatter`_ run in the root directory::

$ black morepath
$ black reg

Black has also integration_ for the most popular editors.

Expand All @@ -105,9 +100,9 @@ Or from the Reg project directory::
Building the HTML documentation
-------------------------------

To build the HTML documentation (output in ``doc/build/html``), run::
To build the HTML documentation (output in ``doc/_build/html``), run::

$ sphinx-build doc doc/build/html
$ sphinx-build doc doc/_build/html

Or alternatively if you have ``Make`` installed::

Expand All @@ -132,11 +127,11 @@ To also show cyclomatic complexity, use this command::

$ flake8 --max-complexity=10 reg

.. _flake8: https://pypi.python.org/pypi/flake8
.. _flake8: https://pypi.org/project/flake8

.. _pyflakes: https://pypi.python.org/pypi/pyflakes
.. _pyflakes: https://pypi.org/project/pyflakes

.. _pep8: http://www.python.org/dev/peps/pep-0008/
.. _pep8: https://peps.python.org/pep-0008

.. _`cyclomatic complexity`: https://en.wikipedia.org/wiki/Cyclomatic_complexity

Expand Down Expand Up @@ -173,4 +168,4 @@ To run a simple performance test you can use::

$ tox -e perf

.. _pyenv: https://github.com/yyuu/pyenv
.. _pyenv: https://github.com/pyenv/pyenv
12 changes: 6 additions & 6 deletions doc/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The core registry (mapping) code was conceived by Thomas Lotze and
Martijn Faassen as a speculative sandbox project in January
of 2010. It was called ``iface`` then:

http://svn.zope.org/Sandbox/faassen/iface/
https://github.com/faassen/iface

This registry was instrumental in getting Reg started, but was
subsequently removed in a later refactoring.
Expand Down Expand Up @@ -103,9 +103,9 @@ refactoring_ to use generic functions throughout and no interfaces for
lookup. Martijn then used this version of Reg in Morepath for about a
year.

.. _announcement: http://blog.startifact.com/posts/reg-component-architecture-reimagined.html
.. _announcement: https://blog.startifact.com/posts/reg-component-architecture-reimagined/

.. _refactoring: http://blog.startifact.com/posts/reg-now-with-more-generic.html
.. _refactoring: https://blog.startifact.com/posts/reg-now-with-more-generic/

Predicate dispatch
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -179,13 +179,13 @@ significant evolution since then. ``zope.interface`` has a long
history, going all the way back to December 1998, when a scarecrow
interface package was released for discussion:

http://old.zope.org/Members/jim/PythonInterfaces/Summary/
https://old.zope.org/Members/jim/PythonInterfaces/Summary/

http://old.zope.org/Members/jim/PythonInterfaces/Interface/
https://old.zope.org/Members/jim/PythonInterfaces/Interface/

A later version of this codebase found itself in Zope, as ``Interface``:

http://svn.zope.org/Zope/tags/2-8-6/lib/python/Interface/
https://github.com/zopefoundation/Zope/tree/2-8-6/lib/python/Interface

A new version called zope.interface was developed for the Zope 3
project, somewhere around the year 2001 or 2002 (code historians,
Expand Down
6 changes: 3 additions & 3 deletions doc/patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ small icon and a large icon. We want this API:
implement the API in a base class either. We just do it in this
example to be explicit.

.. _`abc module`: http://docs.python.org/2/library/abc.html
.. _`abc module`: https://docs.python.org/3/library/abc.html

We define ``Document`` and ``Image`` content classes:

Expand Down Expand Up @@ -207,7 +207,7 @@ follow the open/closed principle and add functionality to a class
without modifying it. This works for instance methods, but what about
``classmethod``? This takes the *class* as the first argument, not an
instance. You can configure ``@reg.dispatch`` decorator with a special
:class:`Predicate` instance that lets you dispatch on a class argument
:class:`reg.Predicate` instance that lets you dispatch on a class argument
instead of an instance argument.

Here's what it looks like:
Expand All @@ -218,7 +218,7 @@ Here's what it looks like:
def something(cls):
raise NotImplementedError()

Note the call to :func:`match_class` here. This lets us specify that
Note the call to :func:`reg.match_class` here. This lets us specify that
we want to dispatch on the class, in this case we simply want the
``cls`` argument.

Expand Down
4 changes: 2 additions & 2 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Predicate dispatch

.. _`dynamic dispatch`: https://en.wikipedia.org/wiki/Dynamic_dispatch

.. _`multiple dispatch`: http://en.wikipedia.org/wiki/Multiple_dispatch
.. _`multiple dispatch`: https://en.wikipedia.org/wiki/Multiple_dispatch

.. _`predicate dispatch`: https://en.wikipedia.org/wiki/Predicate_dispatch

Expand All @@ -56,7 +56,7 @@ Multiple registries
Reg is designed with a caching layer that allows it to support these
features efficiently.

.. _`Morepath`: http://morepath.readthedocs.io
.. _`Morepath`: https://morepath.readthedocs.io

Example
-------
Expand Down
Loading
Loading