From baf8017e500c2245a3a8869a68b2af0ef66ff4ef Mon Sep 17 00:00:00 2001 From: Aric Coady Date: Sat, 2 Nov 2024 11:41:06 -0700 Subject: [PATCH] Python 3.14 tested. --- .github/workflows/build.yml | 2 +- README.md | 2 +- docs/examples.ipynb | 5 +++-- multimethod/__init__.py | 2 +- pyproject.toml | 4 ++++ tests/test_subscripts.py | 5 +++-- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3a525f..64795bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14.0-alpha - 3.14'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/README.md b/README.md index fa71539..cd0bea0 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ If a type implements a custom `__instancecheck__`, it can opt-in to dispatch (wi ```python from multimethod import parametric -Coroutine = parametric(Callable, asyncio.iscoroutinefunction) +Coroutine = parametric(Callable, inspect.iscoroutinefunction) IntArray = parametric(array, typecode='i') ``` diff --git a/docs/examples.ipynb b/docs/examples.ipynb index b8efafe..5aa4108 100644 --- a/docs/examples.ipynb +++ b/docs/examples.ipynb @@ -143,12 +143,13 @@ "outputs": [], "source": [ "import asyncio\n", + "import inspect\n", "import time\n", "from collections.abc import Callable\n", "from concurrent import futures\n", "from multimethod import parametric\n", "\n", - "Coroutine = parametric(Callable, asyncio.iscoroutinefunction)\n", + "Coroutine = parametric(Callable, inspect.iscoroutinefunction)\n", "\n", "\n", "@multimethod\n", @@ -262,7 +263,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.13.0" } }, "nbformat": 4, diff --git a/multimethod/__init__.py b/multimethod/__init__.py index b762b49..c43647f 100644 --- a/multimethod/__init__.py +++ b/multimethod/__init__.py @@ -25,7 +25,7 @@ def get_args(tp) -> tuple: def get_mro(cls) -> tuple: # `inspect.getmro` doesn't handle all cases - return type.mro(cls) if isinstance(cls, type) else cls.mro() + return tuple(type.mro(cls)) if isinstance(cls, type) else cls.mro() def common_bases(*bases): diff --git a/pyproject.toml b/pyproject.toml index 7076f78..f14cd1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Software Development :: Libraries :: Python Modules", "Typing :: Typed", ] @@ -40,3 +41,6 @@ quote-style = "preserve" [tool.coverage.run] source = ["multimethod"] branch = true + +[tool.pytest.ini_options] +markers = ["benchmark"] diff --git a/tests/test_subscripts.py b/tests/test_subscripts.py index abe5948..9aa651e 100644 --- a/tests/test_subscripts.py +++ b/tests/test_subscripts.py @@ -1,4 +1,5 @@ import asyncio +import inspect import sys import typing import pytest @@ -130,10 +131,10 @@ def test_args(): @pytest.mark.benchmark def test_parametric(): - coro = parametric(Callable, asyncio.iscoroutinefunction) + coro = parametric(Callable, inspect.iscoroutinefunction) assert issubclass(coro, Callable) assert not issubclass(Callable, coro) - assert not issubclass(parametric(object, asyncio.iscoroutinefunction), coro) + assert not issubclass(parametric(object, inspect.iscoroutinefunction), coro) assert isinstance(asyncio.sleep, coro) assert not isinstance(lambda: None, coro) assert list(subtype.origins(coro)) == [Callable]