Skip to content

Commit 6a3192f

Browse files
authored
Move all project configuration from setup.py to pyproject.toml (#41)
* Move all project configuration from setup.py to pyproject.toml Enabled mypy `local_partial_types` while I'm at it, makes no changes but ensures behaviour is identical to when mypy is running in daemon mode. * Update continuous integration script to be similar to Trio * Add group for code coverage * Drop 3.7 and run tests for newer python versions
1 parent fa3001f commit 6a3192f

File tree

6 files changed

+172
-89
lines changed

6 files changed

+172
-89
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python: ['3.7', '3.8', '3.9', '3.10']
12+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
1313

1414
steps:
1515
- name: Checkout
@@ -34,7 +34,7 @@ jobs:
3434
strategy:
3535
fail-fast: false
3636
matrix:
37-
python: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']
37+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
3838
check_formatting: ['0']
3939
extra_name: ['']
4040
include:
@@ -70,7 +70,7 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73-
python: ['3.7', '3.8', '3.9', '3.10']
73+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
7474
steps:
7575
- name: Checkout
7676
uses: actions/checkout@v4

ci.sh

+47-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
#!/bin/bash
22

3-
set -ex
3+
set -ex -o pipefail
44

5-
CHECK_FILES="setup.py src tests"
5+
CHECK_FILES="src tests"
66
YAPF_VERSION=0.20.1
77

8-
python -m pip install -U pip setuptools wheel
8+
# Log some general info about the environment
9+
echo "::group::Environment"
10+
uname -a
11+
env | sort
12+
echo "::endgroup::"
913

10-
python setup.py sdist --formats=zip
11-
pip install dist/*.zip
14+
################################################################
15+
# We have a Python environment!
16+
################################################################
1217

18+
echo "::group::Versions"
19+
python -c "import sys, struct; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8)"
20+
echo "::endgroup::"
21+
22+
echo "::group::Install dependencies"
23+
python -m pip install -U pip build
24+
python -m pip --version
25+
26+
python -m build
27+
python -m pip install dist/*.whl
28+
echo "::endgroup::"
29+
30+
echo "::group::Setup for tests"
1331
# Install dependencies.
1432
pip install -Ur test-requirements.txt
33+
echo "::endgroup::"
1534

1635
if [ "$CHECK_FORMATTING" = "1" ]; then
36+
echo "::group::Yapf"
1737
pip install yapf==${YAPF_VERSION} "isort>=5" mypy pyright
1838
if ! yapf -rpd $CHECK_FILES; then
39+
echo "::endgroup::"
1940
cat <<EOF
2041
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2142
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -30,10 +51,15 @@ in your local checkout.
3051
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3152
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3253
EOF
54+
echo "::error:: yapf found issues"
3355
exit 1
56+
else
57+
echo "::endgroup::"
3458
fi
3559

60+
echo "::group::isort"
3661
if ! isort --check-only --diff $CHECK_FILES ; then
62+
echo "::endgroup::"
3763
cat <<EOF
3864
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3965
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -48,10 +74,15 @@ in your local checkout.
4874
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4975
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5076
EOF
77+
echo "::error:: isort found issues"
5178
exit 1
79+
else
80+
echo "::endgroup::"
5281
fi
5382

83+
echo "::group::Mypy"
5484
if ! mypy src/ tests/type_tests.py ; then
85+
echo "::endgroup::"
5586
cat <<EOF
5687
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5788
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -66,9 +97,13 @@ in your local checkout.
6697
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6798
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6899
EOF
100+
echo "::error:: Mypy found issues"
69101
exit 1
102+
else
103+
echo "::endgroup::"
70104
fi
71105

106+
echo "::group::Pyright"
72107
if ! pyright --verifytypes outcome src/outcome/ ; then
73108
cat <<EOF
74109
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -84,12 +119,19 @@ in your local checkout.
84119
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
85120
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86121
EOF
122+
echo "::error:: Pyright found issues"
87123
exit 1
124+
else
125+
echo "::endgroup::"
88126
fi
89127

90128
exit 0
91129
fi
92130

131+
echo "::group:: Run Tests"
93132
pytest -W error -ra -v tests --cov --cov-config=.coveragerc
133+
echo "::endgroup::"
94134

135+
echo "::group:: Code Coverage"
95136
bash <(curl -s https://codecov.io/bash)
137+
echo "::endgroup::"

pyproject.toml

+121-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,133 @@
1+
[build-system]
2+
requires = ["setuptools >= 64"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name="outcome"
7+
description="Capture the outcome of Python function calls."
8+
authors = [{name = "Frazer McLean", email = "frazer@frazermclean.co.uk"}]
9+
license = {text = "MIT OR Apache-2.0"}
10+
keywords = [
11+
"result",
12+
]
13+
classifiers=[
14+
"Development Status :: 5 - Production/Stable",
15+
"Framework :: Trio",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: MIT License",
18+
"License :: OSI Approved :: Apache Software License",
19+
"Operating System :: POSIX :: Linux",
20+
"Operating System :: MacOS :: MacOS X",
21+
"Operating System :: Microsoft :: Windows",
22+
"Programming Language :: Python :: Implementation :: CPython",
23+
"Programming Language :: Python :: Implementation :: PyPy",
24+
"Programming Language :: Python :: 3 :: Only",
25+
"Programming Language :: Python :: 3.8",
26+
"Programming Language :: Python :: 3.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Typing :: Typed",
31+
]
32+
requires-python = ">=3.8"
33+
dependencies = [
34+
# attrs 19.2.0 adds `eq` option to decorators
35+
"attrs>=19.2.0"
36+
]
37+
dynamic = ["version"]
38+
39+
[project.readme]
40+
file = "README.rst"
41+
content-type = "text/x-rst"
42+
43+
[project.urls]
44+
Homepage = "https://github.com/python-trio/outcome"
45+
Documentation = "https://outcome.readthedocs.io/en/latest/"
46+
Changelog = "https://outcome.readthedocs.io/en/latest/history.html"
47+
Chat = "https://gitter.im/python-trio/general"
48+
49+
[tool.setuptools]
50+
# This means, just install *everything* you see under outcome/, even if it
51+
# doesn't look like a source file, so long as it appears in MANIFEST.in:
52+
include-package-data = true
53+
54+
[tool.setuptools.dynamic]
55+
version = {attr = "outcome._version.__version__"}
56+
157
[tool.towncrier]
2-
package = "outcome"
3-
filename = "docs/source/history.rst"
458
directory = "newsfragments"
5-
underlines = ["-", "~", "^"]
59+
filename = "docs/source/history.rst"
660
issue_format = "`#{issue} <https://github.com/python-trio/outcome/issues/{issue}>`__"
61+
# Usage:
62+
# - PRs should drop a file like "issuenumber.feature" in newsfragments
63+
# (or "bugfix", "doc", "removal", "misc"; misc gets no text, we can
64+
# customize this)
65+
# - At release time after bumping version number, run: towncrier
66+
# (or towncrier --draft)
67+
package = "outcome"
68+
package_dir = "src"
69+
underlines = ["-", "~", "^"]
70+
71+
[[tool.towncrier.type]]
72+
directory = "feature"
73+
name = "Features"
74+
showcontent = true
75+
76+
[[tool.towncrier.type]]
77+
directory = "bugfix"
78+
name = "Bugfixes"
79+
showcontent = true
80+
81+
[[tool.towncrier.type]]
82+
directory = "doc"
83+
name = "Improved documentation"
84+
showcontent = true
85+
86+
[[tool.towncrier.type]]
87+
directory = "removal"
88+
name = "Removals without deprecations"
89+
showcontent = true
90+
91+
[[tool.towncrier.type]]
92+
directory = "misc"
93+
name = "Miscellaneous internal changes"
94+
showcontent = true
95+
96+
[tool.coverage.run]
97+
branch = true
98+
source_pkgs = ["outcome", "tests"]
99+
omit = [
100+
"tests/type_tests.py",
101+
]
102+
103+
[tool.coverage.report]
104+
precision = 1
105+
exclude_lines = [
106+
"pragma: no cover",
107+
"abc.abstractmethod",
108+
"if TYPE_CHECKING.*:",
109+
"@overload",
110+
"raise NotImplementedError",
111+
]
112+
partial_branches = [
113+
"pragma: no branch",
114+
"if not TYPE_CHECKING:",
115+
"if .* or not TYPE_CHECKING:",
116+
]
7117

8118
[tool.isort]
9119
combine_as_imports = true
10120
profile = "black"
11121
skip_gitignore = true
122+
skip = ["./build", "./docs"]
123+
known_first_party = ["outcome"]
12124

13125
[tool.mypy]
126+
python_version = "3.8"
127+
14128
# Be strict about use of Mypy
15129
strict = true
130+
local_partial_types = true
16131
warn_unused_ignores = true
17132
warn_unused_configs = true
18133
warn_redundant_casts = true
@@ -34,3 +149,6 @@ disallow_untyped_decorators = true
34149

35150
# DO NOT use `ignore_errors`; it doesn't apply
36151
# downstream and users have to deal with them.
152+
153+
[tool.pytest.ini_options]
154+
asyncio_mode = "strict"

setup.cfg

-27
This file was deleted.

setup.py

-50
This file was deleted.

src/outcome/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is imported from __init__.py and exec'd from setup.py
1+
# This file is imported from __init__.py and parsed by setuptools
22
from typing import TYPE_CHECKING
33

44
if TYPE_CHECKING:

0 commit comments

Comments
 (0)