Skip to content

Commit

Permalink
Move all project configuration from setup.py to pyproject.toml (#41)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
CoolCat467 authored Jul 4, 2024
1 parent fa3001f commit 6a3192f
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 89 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout
Expand All @@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
check_formatting: ['0']
extra_name: ['']
include:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
52 changes: 47 additions & 5 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
#!/bin/bash

set -ex
set -ex -o pipefail

CHECK_FILES="setup.py src tests"
CHECK_FILES="src tests"
YAPF_VERSION=0.20.1

python -m pip install -U pip setuptools wheel
# Log some general info about the environment
echo "::group::Environment"
uname -a
env | sort
echo "::endgroup::"

python setup.py sdist --formats=zip
pip install dist/*.zip
################################################################
# We have a Python environment!
################################################################

echo "::group::Versions"
python -c "import sys, struct; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8)"
echo "::endgroup::"

echo "::group::Install dependencies"
python -m pip install -U pip build
python -m pip --version

python -m build
python -m pip install dist/*.whl
echo "::endgroup::"

echo "::group::Setup for tests"
# Install dependencies.
pip install -Ur test-requirements.txt
echo "::endgroup::"

if [ "$CHECK_FORMATTING" = "1" ]; then
echo "::group::Yapf"
pip install yapf==${YAPF_VERSION} "isort>=5" mypy pyright
if ! yapf -rpd $CHECK_FILES; then
echo "::endgroup::"
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -30,10 +51,15 @@ in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: yapf found issues"
exit 1
else
echo "::endgroup::"
fi

echo "::group::isort"
if ! isort --check-only --diff $CHECK_FILES ; then
echo "::endgroup::"
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -48,10 +74,15 @@ in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: isort found issues"
exit 1
else
echo "::endgroup::"
fi

echo "::group::Mypy"
if ! mypy src/ tests/type_tests.py ; then
echo "::endgroup::"
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -66,9 +97,13 @@ in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: Mypy found issues"
exit 1
else
echo "::endgroup::"
fi

echo "::group::Pyright"
if ! pyright --verifytypes outcome src/outcome/ ; then
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand All @@ -84,12 +119,19 @@ in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: Pyright found issues"
exit 1
else
echo "::endgroup::"
fi

exit 0
fi

echo "::group:: Run Tests"
pytest -W error -ra -v tests --cov --cov-config=.coveragerc
echo "::endgroup::"

echo "::group:: Code Coverage"
bash <(curl -s https://codecov.io/bash)
echo "::endgroup::"
124 changes: 121 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,133 @@
[build-system]
requires = ["setuptools >= 64"]
build-backend = "setuptools.build_meta"

[project]
name="outcome"
description="Capture the outcome of Python function calls."
authors = [{name = "Frazer McLean", email = "frazer@frazermclean.co.uk"}]
license = {text = "MIT OR Apache-2.0"}
keywords = [
"result",
]
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: Trio",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Typing :: Typed",
]
requires-python = ">=3.8"
dependencies = [
# attrs 19.2.0 adds `eq` option to decorators
"attrs>=19.2.0"
]
dynamic = ["version"]

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[project.urls]
Homepage = "https://github.com/python-trio/outcome"
Documentation = "https://outcome.readthedocs.io/en/latest/"
Changelog = "https://outcome.readthedocs.io/en/latest/history.html"
Chat = "https://gitter.im/python-trio/general"

[tool.setuptools]
# This means, just install *everything* you see under outcome/, even if it
# doesn't look like a source file, so long as it appears in MANIFEST.in:
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "outcome._version.__version__"}

[tool.towncrier]
package = "outcome"
filename = "docs/source/history.rst"
directory = "newsfragments"
underlines = ["-", "~", "^"]
filename = "docs/source/history.rst"
issue_format = "`#{issue} <https://github.com/python-trio/outcome/issues/{issue}>`__"
# Usage:
# - PRs should drop a file like "issuenumber.feature" in newsfragments
# (or "bugfix", "doc", "removal", "misc"; misc gets no text, we can
# customize this)
# - At release time after bumping version number, run: towncrier
# (or towncrier --draft)
package = "outcome"
package_dir = "src"
underlines = ["-", "~", "^"]

[[tool.towncrier.type]]
directory = "feature"
name = "Features"
showcontent = true

[[tool.towncrier.type]]
directory = "bugfix"
name = "Bugfixes"
showcontent = true

[[tool.towncrier.type]]
directory = "doc"
name = "Improved documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "removal"
name = "Removals without deprecations"
showcontent = true

[[tool.towncrier.type]]
directory = "misc"
name = "Miscellaneous internal changes"
showcontent = true

[tool.coverage.run]
branch = true
source_pkgs = ["outcome", "tests"]
omit = [
"tests/type_tests.py",
]

[tool.coverage.report]
precision = 1
exclude_lines = [
"pragma: no cover",
"abc.abstractmethod",
"if TYPE_CHECKING.*:",
"@overload",
"raise NotImplementedError",
]
partial_branches = [
"pragma: no branch",
"if not TYPE_CHECKING:",
"if .* or not TYPE_CHECKING:",
]

[tool.isort]
combine_as_imports = true
profile = "black"
skip_gitignore = true
skip = ["./build", "./docs"]
known_first_party = ["outcome"]

[tool.mypy]
python_version = "3.8"

# Be strict about use of Mypy
strict = true
local_partial_types = true
warn_unused_ignores = true
warn_unused_configs = true
warn_redundant_casts = true
Expand All @@ -34,3 +149,6 @@ disallow_untyped_decorators = true

# DO NOT use `ignore_errors`; it doesn't apply
# downstream and users have to deal with them.

[tool.pytest.ini_options]
asyncio_mode = "strict"
27 changes: 0 additions & 27 deletions setup.cfg

This file was deleted.

50 changes: 0 additions & 50 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/outcome/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is imported from __init__.py and exec'd from setup.py
# This file is imported from __init__.py and parsed by setuptools
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand Down

0 comments on commit 6a3192f

Please sign in to comment.