From e62498a3a9f18f553f12357d3cda49572eab41b0 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 21 May 2024 20:19:27 -0500 Subject: [PATCH 1/6] 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. --- pyproject.toml | 138 +++++++++++++++++++++++++++++++++++++--- setup.cfg | 27 -------- setup.py | 50 --------------- src/outcome/_version.py | 2 +- 4 files changed, 130 insertions(+), 87 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml index 1cd2f25..ce3244d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,135 @@ +[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.7", + "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.7" +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 trio/, 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} `__" +# 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.7" + # Be strict about use of Mypy strict = true +local_partial_types = true warn_unused_ignores = true warn_unused_configs = true warn_redundant_casts = true @@ -21,16 +138,19 @@ warn_unreachable = true warn_return_any = true # Avoid subtle backsliding +#disallow_any_decorated = true +disallow_any_generics = true +disallow_any_unimported = true disallow_incomplete_defs = true disallow_subclassing_any = true -disallow_any_unimported = true -disallow_any_generics = true -disallow_any_explicit = false - -check_untyped_defs = true disallow_untyped_calls = true -disallow_untyped_defs = true disallow_untyped_decorators = true +disallow_untyped_defs = true +check_untyped_defs = true +disallow_any_explicit = false # DO NOT use `ignore_errors`; it doesn't apply # downstream and users have to deal with them. + +[tool.pytest.ini_options] +asyncio_mode = "strict" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7e0298f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,27 +0,0 @@ -[bdist_wheel] -universal = 1 - -[isort] -multi_line_output = 4 -skip = ./build, ./docs -# ci/travis.sh installs outcome normally, so isort assumes it's third party -known_first_party = outcome - -[coverage:run] -branch = True -source = - outcome - tests/ -omit = - tests/type_tests.py - -[coverage:report] -precision = 1 -exclude_lines = - pragma: no cover - abc.abstractmethod - if TYPE_CHECKING: - @overload - -[tool:pytest] -asyncio_mode = strict diff --git a/setup.py b/setup.py deleted file mode 100644 index 008d005..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -from setuptools import find_packages, setup - -version = dict() - -with open('src/outcome/_version.py') as fp: - version_mod = fp.read() - -exec(version_mod, version) - -LONG_DESC = open('README.rst').read() - -setup( - name='outcome', - version=version['__version__'], - description='Capture the outcome of Python function calls.', - url='https://github.com/python-trio/outcome', - project_urls={ - "Documentation": "https://outcome.readthedocs.io/en/latest/", - "Chat": "https://gitter.im/python-trio/general", - "Changelog": "https://outcome.readthedocs.io/en/latest/history.html", - }, - long_description=LONG_DESC, - long_description_content_type='text/x-rst', - author='Frazer McLean', - author_email='frazer@frazermclean.co.uk', - license='MIT OR Apache-2.0', - packages=find_packages('src'), - package_dir={'': 'src'}, - include_package_data=True, - install_requires=['attrs>=19.2.0'], - python_requires='>=3.7', - 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 :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Typing :: Typed', - ], -) diff --git a/src/outcome/_version.py b/src/outcome/_version.py index 735885d..45e2e33 100644 --- a/src/outcome/_version.py +++ b/src/outcome/_version.py @@ -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: From 1ce2b921e866f7f79df8a3af85b3c69a20900994 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Tue, 21 May 2024 20:38:59 -0500 Subject: [PATCH 2/6] Update continuous integration script to be similar to Trio --- ci.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/ci.sh b/ci.sh index 85d2a18..2221ff0 100755 --- a/ci.sh +++ b/ci.sh @@ -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, ssl; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)" +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 < Date: Tue, 21 May 2024 20:41:45 -0500 Subject: [PATCH 3/6] Add group for code coverage --- ci.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci.sh b/ci.sh index 2221ff0..5f687c1 100755 --- a/ci.sh +++ b/ci.sh @@ -132,4 +132,6 @@ 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::" \ No newline at end of file From cbfda8ebd7c1d40c644e732d93ce5b1a44f29cf8 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Wed, 22 May 2024 11:24:35 -0500 Subject: [PATCH 4/6] Drop 3.7 and run tests for newer python versions --- .github/workflows/ci.yml | 6 +++--- pyproject.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eff0b74..dd9c4d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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: @@ -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 diff --git a/pyproject.toml b/pyproject.toml index ce3244d..d12600d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers=[ "Programming Language :: Python :: 3.12", "Typing :: Typed", ] -requires-python = ">=3.7" +requires-python = ">=3.8" dependencies = [ # attrs 19.2.0 adds `eq` option to decorators "attrs>=19.2.0" @@ -125,7 +125,7 @@ known_first_party = ["outcome"] [tool.mypy] -python_version = "3.7" +python_version = "3.8" # Be strict about use of Mypy strict = true From 0cd979de523d1c97851822c9a566a2f2c5a5f979 Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Thu, 23 May 2024 23:45:01 -0500 Subject: [PATCH 5/6] Revert mypy changes and remove 3.7 category marker --- pyproject.toml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d12600d..0d0e7f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ classifiers=[ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -123,7 +122,6 @@ skip_gitignore = true skip = ["./build", "./docs"] known_first_party = ["outcome"] - [tool.mypy] python_version = "3.8" @@ -138,16 +136,16 @@ warn_unreachable = true warn_return_any = true # Avoid subtle backsliding -#disallow_any_decorated = true -disallow_any_generics = true -disallow_any_unimported = true disallow_incomplete_defs = true disallow_subclassing_any = true +disallow_any_unimported = true +disallow_any_generics = true +disallow_any_explicit = false + +check_untyped_defs = true disallow_untyped_calls = true -disallow_untyped_decorators = true disallow_untyped_defs = true -check_untyped_defs = true -disallow_any_explicit = false +disallow_untyped_decorators = true # DO NOT use `ignore_errors`; it doesn't apply # downstream and users have to deal with them. From 0b5d1c3f67b7a55f45d96590f52e0c32ca2bacbd Mon Sep 17 00:00:00 2001 From: CoolCat467 <52022020+CoolCat467@users.noreply.github.com> Date: Fri, 24 May 2024 13:27:18 -0500 Subject: [PATCH 6/6] Don't print SSL info and fix comment --- ci.sh | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci.sh b/ci.sh index 5f687c1..dee5ca2 100755 --- a/ci.sh +++ b/ci.sh @@ -16,7 +16,7 @@ echo "::endgroup::" ################################################################ echo "::group::Versions" -python -c "import sys, struct, ssl; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)" +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" diff --git a/pyproject.toml b/pyproject.toml index 0d0e7f0..845e958 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ 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 trio/, even if it +# 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