Skip to content

Commit 74db07e

Browse files
committed
Test on PyPy 3.7
1 parent 6000028 commit 74db07e

15 files changed

+143
-19
lines changed

.github/workflows/python_ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: "windows-2019"
1414
continue-on-error: ${{ matrix.config.experimental }}
1515
env:
16-
USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5'
16+
USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6,pypy-3.7'
1717

1818
strategy:
1919
fail-fast: False
@@ -24,6 +24,8 @@ jobs:
2424
- {python-version: "3.8", testenvs: "py38,build", experimental: False}
2525
- {python-version: "3.9", testenvs: "py39,build", experimental: False}
2626
- {python-version: "3.10.0-alpha.5", testenvs: "py310-dev,build", experimental: True}
27+
- {python-version: "pypy-3.6", testenvs: "pypy36,build", experimental: False}
28+
- {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: False}
2729

2830
steps:
2931
- name: Checkout 🛎️

.github/workflows/python_ci_linux.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: "ubuntu-20.04"
1414
continue-on-error: ${{ matrix.config.experimental }}
1515
env:
16-
USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6'
16+
USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6,pypy-3.7'
1717

1818
strategy:
1919
fail-fast: False
@@ -24,7 +24,8 @@ jobs:
2424
- {python-version: "3.8", testenvs: "py38,build", experimental: False}
2525
- {python-version: "3.9", testenvs: "py39,build", experimental: False}
2626
- {python-version: "3.10.0-alpha.5", testenvs: "py310-dev,build", experimental: True}
27-
- {python-version: "pypy-3.6", testenvs: "pypy3,build", experimental: False}
27+
- {python-version: "pypy-3.6", testenvs: "pypy36,build", experimental: False}
28+
- {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: False}
2829

2930
steps:
3031
- name: Checkout 🛎️

.github/workflows/python_ci_macos.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: "macos-latest"
1414
continue-on-error: ${{ matrix.config.experimental }}
1515
env:
16-
USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6'
16+
USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.5,pypy-3.6,pypy-3.7'
1717

1818
strategy:
1919
fail-fast: False
@@ -24,7 +24,8 @@ jobs:
2424
- {python-version: "3.8", testenvs: "py38,build", experimental: False}
2525
- {python-version: "3.9", testenvs: "py39,build", experimental: False}
2626
- {python-version: "3.10.0-alpha.5", testenvs: "py310-dev,build", experimental: True}
27-
- {python-version: "pypy-3.6", testenvs: "pypy3,build", experimental: False}
27+
- {python-version: "pypy-3.6", testenvs: "pypy36,build", experimental: False}
28+
- {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: False}
2829

2930
steps:
3031
- name: Checkout 🛎️

domdf_python_tools/compat.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# this package
5353
import domdf_python_tools
5454

55-
__all__ = ["importlib_resources", "importlib_metadata", "nullcontext", "PYPY"]
55+
__all__ = ["importlib_resources", "importlib_metadata", "nullcontext", "PYPY", "PYPY36", "PYPY37"]
5656

5757
if sys.version_info[:2] < (3, 7): # pragma: no cover (py37+)
5858
# 3rd party
@@ -111,9 +111,29 @@ def __exit__(self, *excinfo):
111111
# stdlib
112112
from contextlib import nullcontext
113113

114-
PYPY = platform.python_implementation() == "PyPy"
114+
PYPY: bool = platform.python_implementation() == "PyPy"
115115
"""
116116
:py:obj:`True` if running on PyPy rather than CPython.
117117
118118
.. versionadded:: 2.3.0
119119
"""
120+
121+
PYPY36: bool = False
122+
"""
123+
:py:obj:`True` if running on PyPy 3.6.
124+
125+
.. versionadded:: $VERSION
126+
"""
127+
128+
PYPY37: bool = False
129+
"""
130+
:py:obj:`True` if running on PyPy 3.7.
131+
132+
.. versionadded:: $VERSION
133+
"""
134+
135+
if PYPY:
136+
if sys.version_info[:2] == (3, 6):
137+
PYPY36 = True
138+
elif sys.version_info[:2] == (3, 7):
139+
PYPY37 = True

domdf_python_tools/doctools.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828

2929
# stdlib
3030
import builtins
31+
from contextlib import suppress
3132
from inspect import cleandoc
3233
from types import MethodType
3334
from typing import Any, Callable, Dict, Optional, Sequence, Type, TypeVar, Union
3435

3536
# this package
36-
from domdf_python_tools.compat import PYPY
37+
from domdf_python_tools.compat import PYPY, PYPY37
3738
from domdf_python_tools.typing import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType
3839

3940
__all__ = [
@@ -335,6 +336,13 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
335336
continue
336337
elif PYPY and isinstance(attribute, MethodType):
337338
continue # pragma: no cover (!PyPy)
339+
elif PYPY37:
340+
if attribute is getattr(object, attr_name, None):
341+
continue
342+
elif attribute is getattr(float, attr_name, None):
343+
continue
344+
elif attribute is getattr(str, attr_name, None):
345+
continue
338346

339347
if attribute is None:
340348
continue
@@ -345,7 +353,8 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
345353

346354
doc: Optional[str] = attribute.__doc__
347355
if doc in {None, base_docstring}:
348-
attribute.__doc__ = new_docstrings[attr_name]
356+
with suppress(AttributeError, TypeError):
357+
attribute.__doc__ = new_docstrings[attr_name]
349358

350359

351360
def prettify_docstrings(obj: Type) -> Type:
@@ -372,10 +381,8 @@ def prettify_docstrings(obj: Type) -> Type:
372381
if "return" not in annotations or annotations["return"] is Any:
373382
annotations["return"] = new_return_types[attribute]
374383

375-
try:
384+
with suppress(AttributeError, TypeError):
376385
getattr(obj, attribute).__annotations__ = annotations
377-
except AttributeError: # pragma: no cover
378-
pass
379386

380387
if issubclass(obj, tuple) and obj.__repr__.__doc__ == "Return a nicely formatted representation string":
381388
obj.__repr__.__doc__ = repr_docstring

repo_helper.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ python_versions:
1919
- 3.8
2020
- 3.9
2121
- 3.10-dev
22-
- pypy3
22+
- pypy36
23+
- pypy37
2324

2425
classifiers:
2526
- 'Development Status :: 5 - Production/Stable'

tests/test_import_tools.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
discover_entry_points_by_name,
1616
iter_submodules
1717
)
18-
from domdf_python_tools.testing import only_version
18+
from domdf_python_tools.testing import not_pypy, only_pypy, only_version
1919

2020
sys.path.append('.')
2121
sys.path.append("tests")
@@ -129,14 +129,28 @@ def test_discover_entry_points_by_name_name_match_func(data_regression: DataRegr
129129
"version",
130130
[
131131
pytest.param(3.6, marks=only_version(3.6, reason="Output differs on Python 3.6")),
132-
pytest.param(3.7, marks=only_version(3.7, reason="Output differs on Python 3.7")),
132+
pytest.param(
133+
3.7,
134+
marks=[
135+
only_version(3.7, reason="Output differs on Python 3.7"),
136+
not_pypy("Output differs on PyPy")
137+
]
138+
),
139+
pytest.param(
140+
"3.7-pypy",
141+
marks=[
142+
only_version(3.7, reason="Output differs on Python 3.7"),
143+
only_pypy("Output differs on PyPy")
144+
]
145+
),
133146
pytest.param(3.8, marks=only_version(3.8, reason="Output differs on Python 3.8")),
134147
pytest.param(3.9, marks=only_version(3.9, reason="Output differs on Python 3.9")),
135148
pytest.param("3.10", marks=only_version("3.10", reason="Output differs on Python 3.10")),
136149
]
137150
)
138151
@pytest.mark.parametrize(
139-
"module", ["collections", "importlib", "domdf_python_tools", "consolekit", "asyncio", "json"]
152+
"module",
153+
["collections", "importlib", "domdf_python_tools", "consolekit", "asyncio", "json"],
140154
)
141155
def test_iter_submodules(version, module: str, data_regression: DataRegressionFixture):
142156
data_regression.check(list(iter_submodules(module)))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
- asyncio
2+
- asyncio.base_events
3+
- asyncio.base_futures
4+
- asyncio.base_subprocess
5+
- asyncio.base_tasks
6+
- asyncio.compat
7+
- asyncio.constants
8+
- asyncio.coroutines
9+
- asyncio.events
10+
- asyncio.format_helpers
11+
- asyncio.futures
12+
- asyncio.locks
13+
- asyncio.log
14+
- asyncio.proactor_events
15+
- asyncio.protocols
16+
- asyncio.queues
17+
- asyncio.runners
18+
- asyncio.selector_events
19+
- asyncio.sslproto
20+
- asyncio.streams
21+
- asyncio.subprocess
22+
- asyncio.tasks
23+
- asyncio.test_utils
24+
- asyncio.transports
25+
- asyncio.unix_events
26+
- asyncio.windows_events
27+
- asyncio.windows_utils
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- collections
2+
- collections.abc
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- consolekit
2+
- consolekit._types
3+
- consolekit.commands
4+
- consolekit.input
5+
- consolekit.options
6+
- consolekit.terminal_colours
7+
- consolekit.testing
8+
- consolekit.tracebacks
9+
- consolekit.utils

0 commit comments

Comments
 (0)