From fbcae2a8b0e4a6d9227639d4a4293e4241976219 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 10 Aug 2022 14:15:32 +0200 Subject: [PATCH] Switch to 1% static packaging configuration (#998) * Switch to 1% static packaging configuration * Add shim for @pganssle * Not worth interpolation * Kill extra line --- .gitignore | 4 ++-- pyproject.toml | 60 ++++++++++++++++++++++++++++---------------------- setup.py | 27 ++++++++++++----------- tox.ini | 13 +++++------ 4 files changed, 56 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index f5c97f1c..3c89675a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.egg-info *.pyc +.DS_Store .cache .coverage* .direnv @@ -13,5 +14,4 @@ build dist docs/_build/ htmlcov -pip-wheel-metadata -tmp +tmp* diff --git a/pyproject.toml b/pyproject.toml index d100c75a..577350ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,17 @@ +# SPDX-License-Identifier: MIT + [build-system] requires = ["setuptools>=40.6.0", "wheel"] build-backend = "setuptools.build_meta" +[tool.pytest.ini_options] +addopts = ["-ra", "--strict-markers", "--strict-config"] +xfail_strict = true +testpaths = "tests" +filterwarnings = ["once::Warning", "ignore:::pympler[.*]"] + + [tool.coverage.run] parallel = true branch = true @@ -25,6 +34,10 @@ exclude_lines = [ line-length = 79 +[tool.isort] +profile = "attrs" + + [tool.interrogate] verbose = 2 fail-under = 100 @@ -35,37 +48,32 @@ whitelist-regex = ["test_.*"] toplevel = ["attr", "attrs"] -[tool.isort] -profile = "attrs" - - [tool.towncrier] - package = "attr" - package_dir = "src" - filename = "CHANGELOG.rst" - template = "changelog.d/towncrier_template.rst" - issue_format = "`#{issue} `_" - directory = "changelog.d" - title_format = "{version} ({project_date})" - underlines = ["-", "^"] +name = "attrs" +filename = "CHANGELOG.rst" +template = "changelog.d/towncrier_template.rst" +issue_format = "`#{issue} `_" +directory = "changelog.d" +title_format = "{version} ({project_date})" +underlines = ["-", "^"] - [[tool.towncrier.section]] - path = "" +[[tool.towncrier.section]] +path = "" - [[tool.towncrier.type]] - directory = "breaking" - name = "Backwards-incompatible Changes" - showcontent = true +[[tool.towncrier.type]] +directory = "breaking" +name = "Backwards-incompatible Changes" +showcontent = true - [[tool.towncrier.type]] - directory = "deprecation" - name = "Deprecations" - showcontent = true +[[tool.towncrier.type]] +directory = "deprecation" +name = "Deprecations" +showcontent = true - [[tool.towncrier.type]] - directory = "change" - name = "Changes" - showcontent = true +[[tool.towncrier.type]] +directory = "change" +name = "Changes" +showcontent = true [tool.mypy] diff --git a/setup.py b/setup.py index 874fe757..49c00071 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ import codecs import os -import platform import re from setuptools import find_packages, setup @@ -45,25 +44,27 @@ CLASSIFIERS = [ INSTALL_REQUIRES = [] EXTRAS_REQUIRE = { "docs": ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"], - "tests_no_zope": [ + "tests-no-zope": [ # For regression test to ensure cloudpickle compat doesn't break. 'cloudpickle; python_implementation == "CPython"', - # 5.0 introduced toml; parallel was broken until 5.0.2 - "coverage[toml]>=5.0.2", "hypothesis", "pympler", - "pytest>=4.3.0", # 4.3.0 dropped last use of `convert` + # 4.3.0 dropped last use of `convert` + "pytest>=4.3.0", + # Since the mypy error messages keep changing, we have to keep updating + # this pin. + "mypy>=0.971; python_implementation == 'CPython'", + "pytest-mypy-plugins; python_implementation == 'CPython'", ], + "tests": { + "attrs[tests-no-zope]", + "zope.interface", + }, + "dev": {"attrs[tests,docs]": ["pre-commit"]}, } -if platform.python_implementation() != "PyPy": - EXTRAS_REQUIRE["tests_no_zope"].extend( - ["mypy>=0.900,!=0.940", "pytest-mypy-plugins"] - ) +# Don't break Paul unnecessarily just yet. C.f. #685 +EXTRAS_REQUIRE["tests_no_zope"] = EXTRAS_REQUIRE["tests-no-zope"] -EXTRAS_REQUIRE["tests"] = EXTRAS_REQUIRE["tests_no_zope"] + ["zope.interface"] -EXTRAS_REQUIRE["dev"] = ( - EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["docs"] + ["pre-commit"] -) ############################################################################### diff --git a/tox.ini b/tox.ini index 1fd8d925..e837ff8c 100644 --- a/tox.ini +++ b/tox.ini @@ -41,17 +41,18 @@ commands = python -m pytest {posargs} [testenv:py36] extras = tests +deps = coverage[toml] commands = coverage run -m pytest {posargs} [testenv:py310] # Python 3.6+ has a number of compile-time warnings on invalid string escapes. # PYTHONWARNINGS=d and --no-compile below make them visible during the Tox run. -basepython = python3.10 install_command = pip install --no-compile {opts} {packages} setenv = PYTHONWARNINGS=d extras = tests +deps = coverage[toml] commands = coverage run -m pytest {posargs} @@ -59,7 +60,7 @@ commands = coverage run -m pytest {posargs} basepython = python3.10 depends = py36,py310 skip_install = true -deps = coverage[toml]>=5.4 +deps = coverage[toml] commands = coverage combine coverage report @@ -68,11 +69,9 @@ commands = [testenv:pre-commit] basepython = python3.10 skip_install = true -deps = - pre-commit +deps = pre-commit passenv = HOMEPATH # needed on Windows -commands = - pre-commit run --all-files +commands = pre-commit run --all-files [testenv:manifest] @@ -97,7 +96,7 @@ commands = basepython = python3.8 deps = towncrier skip_install = true -commands = towncrier --draft +commands = towncrier build --version UNRELEASED --draft [testenv:typing]