Skip to content

Commit 2412e62

Browse files
authored
fix: officially support Python 3.6 (#40)
1 parent 6b87835 commit 2412e62

File tree

11 files changed

+71
-31
lines changed

11 files changed

+71
-31
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ env:
1010
jobs:
1111
test:
1212
name: "Test Python ${{ matrix.python-version }} on ${{ matrix.os }}"
13-
runs-on: ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}-latest
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest, macos-latest]
17-
python-version: ["3.7", "3.8", "3.9"]
16+
os: [Ubuntu, Windows, macOS]
17+
python-version: ["3.6", "3.7", "3.8", "3.9"]
1818
steps:
1919
- name: "Check out repository"
2020
uses: actions/checkout@v2
@@ -26,14 +26,18 @@ jobs:
2626

2727
- name: "Set up dependency cache"
2828
uses: actions/cache@v2
29+
if: ${{ matrix.os != 'Windows' || matrix.python-version != 3.6 }}
2930
with:
3031
key: deps-${{ secrets.GH_CACHE }}-${{ runner.os }}-python${{ matrix.python-version }}-${{ hashFiles('**/*.lock') }}
3132
path: |
3233
${{ env.PIP_CACHE_DIR }}
3334
${{ env.POETRY_CACHE_DIR }}
3435
36+
- name: "Install poetry"
37+
run: pip install poetry
38+
3539
- name: "Install dependencies"
36-
run: pip install poetry && poetry install
40+
run: poetry install
3741

3842
- name: "Run tests"
3943
run: poetry run pytest
@@ -58,8 +62,11 @@ jobs:
5862
${{ env.PIP_CACHE_DIR }}
5963
${{ env.POETRY_CACHE_DIR }}
6064
65+
- name: "Install poetry"
66+
run: pip install poetry
67+
6168
- name: "Install dependencies"
62-
run: pip install poetry && poetry install
69+
run: poetry install
6370

6471
- name: "Check formatting"
6572
run: poetry run black --check .
@@ -91,8 +98,11 @@ jobs:
9198
${{ env.PIP_CACHE_DIR }}
9299
${{ env.POETRY_CACHE_DIR }}
93100
101+
- name: "Install poetry"
102+
run: pip install poetry
103+
94104
- name: "Install dependencies"
95-
run: pip install poetry && poetry install
105+
run: poetry install
96106

97107
- name: "Build artifacts"
98108
run: |

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Development Setup
44

5-
This project uses [poetry][] to manage dependencies and builds, and you will need to install it before working on Decoy.
5+
This project uses [Poetry][] to manage dependencies and builds, and you will need to install it before working on Decoy.
66

7-
Once poetry is installed, you should be good to set up a virtual environment and install development dependencies. While Decoy is supported on Python >= 3.7, Python >= 3.8 is recommended for development.
7+
Once Poetry is installed, you should be good to set up a virtual environment and install development dependencies. While Decoy supports Python >= 3.6, Python >= 3.8 is recommended for development.
88

99
```bash
1010
git clone https://github.com/mcous/decoy.git

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
<img src="https://mike.cousins.io/decoy/img/decoy.png" width="256px">
44
<p>Opinionated mocking library for Python</p>
55
<p>
6-
<a href="https://github.com/mcous/decoy/actions">
7-
<img title="CI Status" src="https://flat.badgen.net/github/checks/mcous/decoy/main">
6+
<a title="CI Status" href="https://github.com/mcous/decoy/actions">
7+
<img src="https://flat.badgen.net/github/checks/mcous/decoy/main">
88
</a>
9-
<a href="https://pypi.org/project/decoy/">
10-
<img title="PyPI Version" src="https://flat.badgen.net/pypi/v/decoy">
9+
<a title="License" href="https://github.com/mcous/decoy/blob/main/LICENSE">
10+
<img src="https://flat.badgen.net/github/license/mcous/decoy">
1111
</a>
12-
<a href="https://github.com/mcous/decoy/blob/main/LICENSE">
13-
<img title="License" src="https://flat.badgen.net/github/license/mcous/decoy">
12+
<a title="PyPI Version"href="https://pypi.org/project/decoy/">
13+
<img src="https://flat.badgen.net/pypi/v/decoy">
14+
</a>
15+
<a title="Supported Python Versions" href="https://pypi.org/project/decoy/">
16+
<img src="https://flat.badgen.net/pypi/python/decoy">
1417
</a>
1518
</p>
1619
<p>

decoy/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Decoy stubbing and spying library."""
2-
from __future__ import annotations
32
from typing import Any, Callable, Generic, Optional, cast, overload
43

54
from . import matchers, errors, warnings
@@ -88,7 +87,7 @@ def create_decoy_func(
8887
spy = self._core.mock(spec=spec, is_async=is_async)
8988
return cast(FuncT, spy)
9089

91-
def when(self, _rehearsal_result: ReturnT) -> Stub[ReturnT]:
90+
def when(self, _rehearsal_result: ReturnT) -> "Stub[ReturnT]":
9291
"""Create a [Stub][decoy.Stub] configuration using a rehearsal call.
9392
9493
See [stubbing usage guide](../usage/when) for more details.

decoy/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Decoy implementation logic."""
2-
from __future__ import annotations
32
from typing import Any, Callable, Optional
43

54
from .spy import SpyConfig, SpyFactory, create_spy as default_create_spy
@@ -44,7 +43,7 @@ def mock(self, *, spec: Optional[Any] = None, is_async: bool = False) -> Any:
4443
)
4544
return self._create_spy(config)
4645

47-
def when(self, _rehearsal: ReturnT) -> StubCore:
46+
def when(self, _rehearsal: ReturnT) -> "StubCore":
4847
"""Create a new stub from the last spy rehearsal."""
4948
rehearsal = self._call_stack.consume_when_rehearsal()
5049
return StubCore(rehearsal=rehearsal, stub_store=self._stub_store)

decoy/spy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Classes in this module are heavily inspired by the
44
[unittest.mock library](https://docs.python.org/3/library/unittest.mock.html).
55
"""
6-
from __future__ import annotations
76
from inspect import isclass, iscoroutinefunction, isfunction, signature
87
from functools import partial
98
from typing import get_type_hints, Any, Callable, Dict, NamedTuple, Optional

poetry.lock

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "decoy"
33
version = "1.6.0"
4-
description = "Opinionated, typed stubbing and verification library for Python"
4+
description = "Opinionated mocking library for Python"
55
authors = ["Mike Cousins <[email protected]>"]
66
license = "MIT"
77
readme = "README.md"
@@ -18,8 +18,11 @@ classifiers = [
1818
"Typing :: Typed",
1919
]
2020

21+
[tool.poetry.urls]
22+
"Changelog" = "https://github.com/mcous/decoy/releases"
23+
2124
[tool.poetry.dependencies]
22-
python = "^3.7"
25+
python = "^3.6.2"
2326

2427
[tool.poetry.dev-dependencies]
2528
black = "^21.5b1"
@@ -48,5 +51,5 @@ strict = true
4851
show_error_codes = true
4952

5053
[build-system]
51-
requires = ["poetry>=0.12"]
52-
build-backend = "poetry.masonry.api"
54+
requires = ["poetry_core>=1.0.0"]
55+
build-backend = "poetry.core.masonry.api"

tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def do_the_thing(self, flag: bool) -> None:
4848

4949

5050
# NOTE: these `Any`s are forward references for call signature testing purposes
51-
def noop(*args: "Any", **kwargs: "Any") -> "Any":
51+
def noop(*args: Any, **kwargs: Any) -> Any:
5252
"""No-op."""
5353
pass
5454

tests/test_matchers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""Matcher tests."""
22
import pytest
33
from collections import namedtuple
4-
from dataclasses import dataclass
54
from decoy import matchers
6-
from typing import Any, List
5+
from typing import Any, List, NamedTuple
76
from .common import SomeClass
87

98

10-
@dataclass
11-
class _HelloClass:
9+
class _HelloClass(NamedTuple):
1210
hello: str = "world"
1311

1412
@property

0 commit comments

Comments
 (0)