From 375b9928165cb1ba91ecf2640ebbbc5ed2ec03a6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 26 Jan 2024 13:58:43 -0500 Subject: [PATCH 01/26] build: bump version --- CHANGES.rst | 6 ++++++ coverage/version.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a65101ea6..98934427a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,12 @@ development at the same time, such as 4.5.x and 5.0. .. Version 9.8.1 — 2027-07-27 .. -------------------------- +Unreleased +---------- + +Nothing yet. + + .. scriv-start-here .. _changes_7-4-1: diff --git a/coverage/version.py b/coverage/version.py index 2f953e709..1aef04bd6 100644 --- a/coverage/version.py +++ b/coverage/version.py @@ -8,8 +8,8 @@ # version_info: same semantics as sys.version_info. # _dev: the .devN suffix if any. -version_info = (7, 4, 1, "final", 0) -_dev = 0 +version_info = (7, 4, 2, "alpha", 0) +_dev = 1 def _make_version( From c24db6d51be3e1b5de10ae43af145ed071b78456 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 27 Jan 2024 13:45:08 +0200 Subject: [PATCH 02/26] CI: Set PYTHON_COLORS=0 to disable coloured CPython tracebacks (#1740) test: prevent Python from using colors instead of removing color from its output * Revert "test: ignore color in tracebacks" This reverts commit 75b22f0e24559446ff551acb6ddbaa92bce8add3. * Set PYTHON_COLORS=0 to disable coloured CPython tracebacks * Set PYTHON_COLORS=0 to disable coloured CPython tracebacks globally in tox.ini --- tests/helpers.py | 5 ----- tests/test_execfile.py | 3 +-- tests/test_process.py | 11 +++-------- tests/test_testing.py | 14 +------------- tox.ini | 2 ++ 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index 03e694db2..9e6e2e8de 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -397,8 +397,3 @@ def __init__(self, options: Iterable[str]) -> None: def get_output(self) -> str: """Get the output text from the `DebugControl`.""" return self.io.getvalue() - - -def without_color(text: str) -> str: - """Remove ANSI color-setting escape sequences.""" - return re.sub(r"\033\[[\d;]+m", "", text) diff --git a/tests/test_execfile.py b/tests/test_execfile.py index c3791e635..908857942 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -23,7 +23,6 @@ from coverage.files import python_reported_file from tests.coveragetest import CoverageTest, TESTS_DIR, UsingModulesMixin -from tests.helpers import without_color TRY_EXECFILE = os.path.join(TESTS_DIR, "modules/process_test/try_execfile.py") @@ -189,7 +188,7 @@ def excepthook(*args): run_python_file(["excepthook_throw.py"]) # The _ExceptionDuringRun exception has the RuntimeError as its argument. assert exc_info.value.args[1].args[0] == "Error Outside" - stderr = without_color(self.stderr()) + stderr = self.stderr() assert "in excepthook\n" in stderr assert "Error in sys.excepthook:\n" in stderr assert "RuntimeError: Error Inside" in stderr diff --git a/tests/test_process.py b/tests/test_process.py index a5db56b69..5aeb49744 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -27,7 +27,7 @@ from tests import testenv from tests.coveragetest import CoverageTest, TESTS_DIR -from tests.helpers import re_line, re_lines, re_lines_text, without_color +from tests.helpers import re_line, re_lines, re_lines_text class ProcessTest(CoverageTest): @@ -318,7 +318,6 @@ def f2(): assert out == out2 # But also make sure that the output is what we expect. - out = without_color(out) path = python_reported_file('throw.py') msg = f'File "{re.escape(path)}", line 8, in f2' assert re.search(msg, out) @@ -970,11 +969,8 @@ def excepthook(*args): py_st, py_out = self.run_command_status("python excepthook_throw.py") assert cov_st == py_st assert cov_st == 1 - assert "in excepthook" in without_color(py_out) - # Don't know why: the Python output shows "Error in sys.excepthook" and - # "Original exception" in color. The coverage output has the first in - # color and "Original" without color? Strip all the color. - assert without_color(cov_out) == without_color(py_out) + assert "in excepthook" in py_out + assert cov_out == py_out class AliasedCommandTest(CoverageTest): @@ -1181,7 +1177,6 @@ def test_removing_directory(self) -> None: def test_removing_directory_with_error(self) -> None: self.make_file("bug806.py", self.BUG_806) out = self.run_command("coverage run bug806.py") - out = without_color(out) path = python_reported_file('bug806.py') # Python 3.11 adds an extra line to the traceback. # Check that the lines we expect are there. diff --git a/tests/test_testing.py b/tests/test_testing.py index 1af6613ea..3c3b0622e 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -24,7 +24,7 @@ from tests.helpers import ( CheckUniqueFilenames, FailingProxy, arcs_to_arcz_repr, arcz_to_arcs, assert_count_equal, assert_coverage_warnings, - re_lines, re_lines_text, re_line, without_color, + re_lines, re_lines_text, re_line, ) @@ -472,15 +472,3 @@ def subtract(self, a, b): # type: ignore[no-untyped-def] proxy.add(3, 4) # then add starts working assert proxy.add(5, 6) == 11 - - -@pytest.mark.parametrize("text, result", [ - ("", ""), - ("Nothing to see here", "Nothing to see here"), - ("Oh no! \x1b[1;35mRuntimeError\x1b[0m. Fix it.", "Oh no! RuntimeError. Fix it."), - ("Fancy: \x1b[48;5;95mBkgd\x1b[38;2;100;200;25mRGB\x1b[0m", "Fancy: BkgdRGB"), - # Other escape sequences are unaffected. - ("X\x1b[2J\x1b[1mBold\x1b[22m\x1b[=3hZ", "X\x1b[2JBold\x1b[=3hZ"), -]) -def test_without_color(text: str, result: str) -> None: - assert without_color(text) == result diff --git a/tox.ini b/tox.ini index 746b9a785..ecd6d65fa 100644 --- a/tox.ini +++ b/tox.ini @@ -32,6 +32,8 @@ setenv = PYTHONPYCACHEPREFIX= # If we ever need a stronger way to suppress warnings: #PYTHONWARNINGS=ignore:removed in Python 3.14; use ast.Constant:DeprecationWarning + # Disable CPython's color output + PYTHON_COLORS=0 # $set_env.py: COVERAGE_PIP_ARGS - Extra arguments for `pip install` # `--no-build-isolation` will let tox work with no network. From 88e32a479e242f55a53d3e5464c49fcd62766e98 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 26 Jan 2024 13:46:36 -0500 Subject: [PATCH 03/26] build: rework requests authentication throughout I have a read-only GitHub token in my .netrc. I can put write-enabled tokens into the GITHUB_TOKEN environment variable. I need to give the token to requests, and I need to tell it to ignore my .netrc. --- ci/comment_on_fixes.py | 8 ++++---- ci/download_gha_artifacts.py | 7 +++---- ci/session.py | 27 +++++++++++++++++++++++++++ ci/trigger_build_kits.py | 11 +++++++---- 4 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 ci/session.py diff --git a/ci/comment_on_fixes.py b/ci/comment_on_fixes.py index 08b4dee06..2f7dbdc47 100644 --- a/ci/comment_on_fixes.py +++ b/ci/comment_on_fixes.py @@ -7,7 +7,7 @@ import re import sys -import requests +from session import get_session with open("tmp/relnotes.json") as frn: relnotes = json.load(frn) @@ -27,14 +27,14 @@ if kind == "issues": url = f"https://api.github.com/repos/{repo_owner}/issues/{number}" - issue_data = requests.get(url).json() + issue_data = get_session().get(url).json() if issue_data["state"] == "closed": do_comment = True else: print(f"Still open, comment manually: {m[0]}") else: url = f"https://api.github.com/repos/{repo_owner}/pulls/{number}" - pull_data = requests.get(url).json() + pull_data = get_session().get(url).json() if pull_data["state"] == "closed": if pull_data["merged"]: do_comment = True @@ -46,5 +46,5 @@ if do_comment: print(f"Commenting on {m[0]}") url = f"https://api.github.com/repos/{repo_owner}/issues/{number}/comments" - resp = requests.post(url, json={"body": comment}) + resp = get_session().post(url, json={"body": comment}) print(resp) diff --git a/ci/download_gha_artifacts.py b/ci/download_gha_artifacts.py index bb866833f..d91add0c3 100644 --- a/ci/download_gha_artifacts.py +++ b/ci/download_gha_artifacts.py @@ -13,12 +13,11 @@ import time import zipfile -import requests - +from session import get_session def download_url(url, filename): """Download a file from `url` to `filename`.""" - response = requests.get(url, stream=True) + response = get_session().get(url, stream=True) if response.status_code == 200: with open(filename, "wb") as f: for chunk in response.iter_content(16*1024): @@ -60,7 +59,7 @@ def all_items(url, key): """ url += ("&" if "?" in url else "?") + "per_page=100" while url: - response = requests.get(url) + response = get_session().get(url) response.raise_for_status() data = response.json() if isinstance(data, dict) and (msg := data.get("message")): diff --git a/ci/session.py b/ci/session.py new file mode 100644 index 000000000..48c6f0bcb --- /dev/null +++ b/ci/session.py @@ -0,0 +1,27 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt + +"""Help make a requests Session with proper authentication.""" + +import os + +import requests + +_SESSION = None + +def get_session(): + """Get a properly authenticated requests Session.""" + + global _SESSION + + if _SESSION is None: + # If GITHUB_TOKEN is in the environment, use it. + _SESSION = requests.session() + token = os.environ.get("GITHUB_TOKEN") + if token is not None: + _SESSION.headers["Authorization"] = f"token {token}" + # requests.get() will always prefer the .netrc file even if a header + # is already set. This tells it to ignore the .netrc file. + _SESSION.trust_env = False + + return _SESSION diff --git a/ci/trigger_build_kits.py b/ci/trigger_build_kits.py index 0485df10a..4751016aa 100644 --- a/ci/trigger_build_kits.py +++ b/ci/trigger_build_kits.py @@ -5,7 +5,7 @@ import sys -import requests +from session import get_session repo_owner = sys.argv[1] @@ -18,9 +18,12 @@ # - build-kits # -resp = requests.post( +resp = get_session().post( f"https://api.github.com/repos/{repo_owner}/dispatches", json={"event_type": "build-kits"}, ) -print(f"Status: {resp.status_code}") -print(resp.text) +if resp.status_code // 100 == 2: + print("Success") +else: + print(f"Status: {resp.status_code}") + print(resp.text) From 0725560138c2df693995a59dd72599efabe123f5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 26 Jan 2024 14:08:37 -0500 Subject: [PATCH 04/26] build: re-skip mac pypy for metacov, ubuntu handles those cases --- .github/workflows/coverage.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5bd88afa1..2cdbd9ded 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -55,10 +55,13 @@ jobs: - "pypy-3.9" - "pypy-3.10" exclude: - # Mac PyPy always takes the longest, and doesn't add anything. Skip - # 3.8, but use 3.9/3.10 while Windows is still borked. + # Mac PyPy always takes the longest, and doesn't add anything. - os: macos python-version: "pypy-3.8" + - os: macos + python-version: "pypy-3.9" + - os: macos + python-version: "pypy-3.10" # Windows pypy 3.9 and 3.10 get stuck with PyPy 7.3.15. I hope to # unstick them, but I don't want that to block all other progress, so # skip them for now. From 6734216d2bd53a3d5e9113fb17e65b14d9db0c76 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 28 Jan 2024 07:26:39 -0500 Subject: [PATCH 05/26] chore: make upgrade (pytest 8.0.0) --- requirements/dev.pip | 8 ++++---- requirements/kit.pip | 2 +- requirements/mypy.pip | 6 +++--- requirements/pytest.pip | 6 +++--- requirements/tox.pip | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/requirements/dev.pip b/requirements/dev.pip index a6a17e250..091e01668 100644 --- a/requirements/dev.pip +++ b/requirements/dev.pip @@ -27,7 +27,7 @@ colorama==0.4.6 # -r requirements/pytest.in # -r requirements/tox.in # tox -dill==0.3.7 +dill==0.3.8 # via pylint distlib==0.3.8 # via virtualenv @@ -47,7 +47,7 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==3.0.3 # via -r requirements/dev.in -hypothesis==6.96.4 +hypothesis==6.97.1 # via -r requirements/pytest.in idna==3.6 # via requests @@ -96,7 +96,7 @@ platformdirs==4.1.0 # pylint # tox # virtualenv -pluggy==1.3.0 +pluggy==1.4.0 # via # pytest # tox @@ -113,7 +113,7 @@ pyproject-api==1.6.1 # via tox pyproject-hooks==1.0.0 # via build -pytest==7.4.4 +pytest==8.0.0 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/kit.pip b/requirements/kit.pip index f55efadf9..5d4fcd70d 100644 --- a/requirements/kit.pip +++ b/requirements/kit.pip @@ -14,7 +14,7 @@ build==1.0.3 # via -r requirements/kit.in certifi==2023.11.17 # via cibuildwheel -cibuildwheel==2.16.2 +cibuildwheel==2.16.3 # via -r requirements/kit.in colorama==0.4.6 # via -r requirements/kit.in diff --git a/requirements/mypy.pip b/requirements/mypy.pip index 437f1c92c..0715678f7 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -16,7 +16,7 @@ execnet==2.0.2 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.96.4 +hypothesis==6.97.1 # via -r requirements/pytest.in iniconfig==2.0.0 # via pytest @@ -26,9 +26,9 @@ mypy-extensions==1.0.0 # via mypy packaging==23.2 # via pytest -pluggy==1.3.0 +pluggy==1.4.0 # via pytest -pytest==7.4.4 +pytest==8.0.0 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/pytest.pip b/requirements/pytest.pip index e40278a69..47e699953 100644 --- a/requirements/pytest.pip +++ b/requirements/pytest.pip @@ -16,15 +16,15 @@ execnet==2.0.2 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.96.4 +hypothesis==6.97.1 # via -r requirements/pytest.in iniconfig==2.0.0 # via pytest packaging==23.2 # via pytest -pluggy==1.3.0 +pluggy==1.4.0 # via pytest -pytest==7.4.4 +pytest==8.0.0 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/tox.pip b/requirements/tox.pip index 8ed94b4e3..874cc77fd 100644 --- a/requirements/tox.pip +++ b/requirements/tox.pip @@ -26,7 +26,7 @@ platformdirs==4.1.0 # via # tox # virtualenv -pluggy==1.3.0 +pluggy==1.4.0 # via tox pyproject-api==1.6.1 # via tox From 619c41fc85b992b26b35e9f46592fedd387be86d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 28 Jan 2024 07:44:51 -0500 Subject: [PATCH 06/26] test: install pygments for syntax coloring, and always get full diffs --- pyproject.toml | 3 +++ requirements/dev.pip | 1 + requirements/mypy.pip | 2 ++ requirements/pytest.in | 1 + requirements/pytest.pip | 2 ++ 5 files changed, 9 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 0cafdb235..cd523c404 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,6 +126,9 @@ filterwarnings = [ # xfail tests that pass should fail the test suite xfail_strict = true +# https://docs.pytest.org/en/stable/reference/reference.html#confval-verbosity_assertions +verbosity_assertions = 5 + balanced_clumps = [ # Because of expensive session-scoped fixture: "VirtualenvTest", diff --git a/requirements/dev.pip b/requirements/dev.pip index 091e01668..be4d627dd 100644 --- a/requirements/dev.pip +++ b/requirements/dev.pip @@ -104,6 +104,7 @@ pudb==2024.1 # via -r requirements/dev.in pygments==2.17.2 # via + # -r requirements/pytest.in # pudb # readme-renderer # rich diff --git a/requirements/mypy.pip b/requirements/mypy.pip index 0715678f7..5b8c07e29 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -28,6 +28,8 @@ packaging==23.2 # via pytest pluggy==1.4.0 # via pytest +pygments==2.17.2 + # via -r requirements/pytest.in pytest==8.0.0 # via # -r requirements/pytest.in diff --git a/requirements/pytest.in b/requirements/pytest.in index 2b23477bd..611b40d8f 100644 --- a/requirements/pytest.in +++ b/requirements/pytest.in @@ -8,6 +8,7 @@ flaky hypothesis +pygments # so that pytest will syntax-color. pytest pytest-xdist diff --git a/requirements/pytest.pip b/requirements/pytest.pip index 47e699953..5e20c7f42 100644 --- a/requirements/pytest.pip +++ b/requirements/pytest.pip @@ -24,6 +24,8 @@ packaging==23.2 # via pytest pluggy==1.4.0 # via pytest +pygments==2.17.2 + # via -r requirements/pytest.in pytest==8.0.0 # via # -r requirements/pytest.in From 8d4afefdac00b6d300f36f3b5f440087ec9c35b8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 2 Feb 2024 15:01:13 -0500 Subject: [PATCH 07/26] docs: an Other Resources page --- doc/faq.rst | 21 +-------- doc/index.rst | 1 + doc/other.rst | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 20 deletions(-) create mode 100644 doc/other.rst diff --git a/doc/faq.rst b/doc/faq.rst index d4f5a565e..500182e7b 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -136,25 +136,6 @@ It's good, but `it isn't perfect`__. __ https://nedbatchelder.com/blog/200710/flaws_in_coverage_measurement.html -.. Other resources - --------------- - - There are a number of projects that help integrate coverage.py into other - systems: - - - `trialcoverage`_ is a plug-in for Twisted trial. - - .. _trialcoverage: https://pypi.org/project/trialcoverage/ - - - `pytest-cov`_ - - .. _pytest-cov: https://pypi.org/project/pytest-cov/ - - - `django-coverage`_ for use with Django. - - .. _django-coverage: https://pypi.org/project/django-coverage/ - - Q: Where can I get more help with coverage.py? .............................................. @@ -168,7 +149,7 @@ Bug reports are gladly accepted at the `GitHub issue tracker`_. .. _GitHub issue tracker: https://github.com/nedbat/coveragepy/issues -`I can be reached`__ in a number of ways, I'm happy to answer questions about +`I can be reached`__ in a number of ways. I'm happy to answer questions about using coverage.py. __ https://nedbatchelder.com/site/aboutned.html diff --git a/doc/index.rst b/doc/index.rst index 522c4a6bf..9ebcde8c5 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -240,6 +240,7 @@ More information api howitworks plugins + other contributing trouble faq diff --git a/doc/other.rst b/doc/other.rst new file mode 100644 index 000000000..eeb8291ae --- /dev/null +++ b/doc/other.rst @@ -0,0 +1,116 @@ +.. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +.. For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt + +.. _other: + +=============== +Other resources +=============== + + +There are a number of projects that help integrate coverage.py into other +systems, provide help using it, offer assistance, and so on. + +There's no guarantee these items are maintained or work well. Some of them +seem to be quite old. If you have suggestions for updates to this page, `open +a pull request`_ or `get in touch`_ some other way. + +.. _open a pull request: https://github.com/nedbat/coveragepy/blob/master/doc/other.rst +.. _get in touch: https://nedbatchelder.com/site/aboutned.html + +Test runners +------------ + +Helpers for using coverage with specific test runners. + +- `pytest-cov`__ is a pytest plugin to coordinate coverage.py usage. + +__ https://pypi.org/project/pytest-cov/ + +- `trialcoverage`__ is a plug-in for Twisted trial. + +__ https://pypi.org/project/trialcoverage/ + + +Configuration helpers +--------------------- + +Tools to provide more control over how coverage is configured. + +- `covdefaults`__ provides "sensible" default settings for coverage. + +__ https://github.com/asottile/covdefaults + +- `coverage-conditional-plugin`__ lets you use conditions instead of simple "no + cover" pragmas to control what lines are considered under different + conditions. + +__ https://github.com/wemake-services/coverage-conditional-plugin + + +Language plugins +---------------- + +Coverage.py plugins to enable coverage measurement of other languages. + +- `django-coverage`__ measures the coverage of Django templates. + +__ https://pypi.org/project/django-coverage/ + +- `Cython`__ provides a plugin for measuring Cythonized code. + +__ https://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html#enabling-coverage-analysis + +- `coverage-jinja-plugin`__ is an incomplete Jinja2 plugin. + +__ https://github.com/MrSenko/coverage-jinja-plugin + +- `hy-coverage`__ supports the Hy language. + +__ https://github.com/timmartin/hy-coverage + + +Reporting helpers +----------------- + +Helpers for seeing the results. + +- `python-coverage-comment-action`__ can publish a delta coverage report as a + pull request comment, create a coverage badge, or a dashboard to display in + your readme. + +__ https://github.com/py-cov-action/python-coverage-comment-action + +- `diff-cover`__ reports on the coverage of lines changed in a pull request. + +__ https://pypi.org/project/diff-cover/ + +- `cuvner`__ offers alternate visualizations of coverage data, including ones + for use in terminals. + +__ https://meejah.ca/projects/cuvner + +- `emacs-python-coverage`__ is an experimental Emacs package to report code + coverage output produced by Python's coverage package directly inside Emacs + buffers. + +__ https://github.com/wbolster/emacs-python-coverage + +- `python-genbadge`__ provides a set of commandline utilities to generate badges for tools that do not provide one, + including coverage badges. + +__ https://smarie.github.io/python-genbadge/ + + +GitHub Action articles +---------------------- + +How to use GitHub Actions for reporting. + +- `How to Ditch Codecov for Python Projects`__ + +__ https://hynek.me/articles/ditch-codecov-python/ + +- `Making a coverage badge`__ + +__ https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html From 25ae1939596ff62abb8f9f801c478cae07968a06 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 2 Feb 2024 16:15:31 -0500 Subject: [PATCH 08/26] docs: no latex on readthedocs please The builds were failing in LaTeX, but I don't know what it's for anyway, so try to stop them. --- .readthedocs.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1960ebca2..19ebe6385 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -17,7 +17,9 @@ sphinx: configuration: doc/conf.py # Build all the formats -formats: all +formats: + - epub + - htmlzip python: install: From 798023b00cfadc3178496b38adc7dea88bf38c27 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 2 Feb 2024 16:29:26 -0500 Subject: [PATCH 09/26] docs: only build HTML I don't understand why LaTeX is involved at all. Try to make it stop. --- .readthedocs.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 19ebe6385..b02536f1a 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -16,10 +16,8 @@ sphinx: builder: html configuration: doc/conf.py -# Build all the formats -formats: - - epub - - htmlzip +# Don't build anything except HTML. +formats: [] python: install: From 23576b1cdf8b90b5c70a0e081d1706277baf27e3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 3 Feb 2024 06:09:05 -0500 Subject: [PATCH 10/26] docs: add coverage-sh as an other --- doc/other.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/other.rst b/doc/other.rst index eeb8291ae..9f6553359 100644 --- a/doc/other.rst +++ b/doc/other.rst @@ -65,6 +65,11 @@ __ https://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html# __ https://github.com/MrSenko/coverage-jinja-plugin +- `coverage-sh`__ measures code coverage of shell (sh or bash) scripts executed + from Python with subprocess. + +__ https://github.com/lackhove/coverage-sh + - `hy-coverage`__ supports the Hy language. __ https://github.com/timmartin/hy-coverage From 90071a032e0d0b2f6a1ebda4e8aff9e8be3e5ad8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 3 Feb 2024 06:37:29 -0500 Subject: [PATCH 11/26] docs(style): fix the bullets --- doc/other.rst | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/doc/other.rst b/doc/other.rst index 9f6553359..a53f634b2 100644 --- a/doc/other.rst +++ b/doc/other.rst @@ -23,13 +23,13 @@ Test runners Helpers for using coverage with specific test runners. -- `pytest-cov`__ is a pytest plugin to coordinate coverage.py usage. +* `pytest-cov`__ is a pytest plugin to coordinate coverage.py usage. -__ https://pypi.org/project/pytest-cov/ + __ https://pypi.org/project/pytest-cov/ -- `trialcoverage`__ is a plug-in for Twisted trial. +* `trialcoverage`__ is a plug-in for Twisted trial. -__ https://pypi.org/project/trialcoverage/ + __ https://pypi.org/project/trialcoverage/ Configuration helpers @@ -37,15 +37,15 @@ Configuration helpers Tools to provide more control over how coverage is configured. -- `covdefaults`__ provides "sensible" default settings for coverage. +* `covdefaults`__ provides "sensible" default settings for coverage. -__ https://github.com/asottile/covdefaults + __ https://github.com/asottile/covdefaults -- `coverage-conditional-plugin`__ lets you use conditions instead of simple "no +* `coverage-conditional-plugin`__ lets you use conditions instead of simple "no cover" pragmas to control what lines are considered under different conditions. -__ https://github.com/wemake-services/coverage-conditional-plugin + __ https://github.com/wemake-services/coverage-conditional-plugin Language plugins @@ -53,26 +53,26 @@ Language plugins Coverage.py plugins to enable coverage measurement of other languages. -- `django-coverage`__ measures the coverage of Django templates. +* `django-coverage`__ measures the coverage of Django templates. -__ https://pypi.org/project/django-coverage/ + __ https://pypi.org/project/django-coverage/ -- `Cython`__ provides a plugin for measuring Cythonized code. +* `Cython`__ provides a plugin for measuring Cythonized code. -__ https://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html#enabling-coverage-analysis + __ https://cython.readthedocs.io/en/latest/src/tutorial/profiling_tutorial.html#enabling-coverage-analysis -- `coverage-jinja-plugin`__ is an incomplete Jinja2 plugin. +* `coverage-jinja-plugin`__ is an incomplete Jinja2 plugin. -__ https://github.com/MrSenko/coverage-jinja-plugin + __ https://github.com/MrSenko/coverage-jinja-plugin -- `coverage-sh`__ measures code coverage of shell (sh or bash) scripts executed +* `coverage-sh`__ measures code coverage of shell (sh or bash) scripts executed from Python with subprocess. -__ https://github.com/lackhove/coverage-sh + __ https://github.com/lackhove/coverage-sh -- `hy-coverage`__ supports the Hy language. +* `hy-coverage`__ supports the Hy language. -__ https://github.com/timmartin/hy-coverage + __ https://github.com/timmartin/hy-coverage Reporting helpers @@ -80,31 +80,31 @@ Reporting helpers Helpers for seeing the results. -- `python-coverage-comment-action`__ can publish a delta coverage report as a +* `python-coverage-comment-action`__ can publish a delta coverage report as a pull request comment, create a coverage badge, or a dashboard to display in your readme. -__ https://github.com/py-cov-action/python-coverage-comment-action + __ https://github.com/py-cov-action/python-coverage-comment-action -- `diff-cover`__ reports on the coverage of lines changed in a pull request. +* `diff-cover`__ reports on the coverage of lines changed in a pull request. -__ https://pypi.org/project/diff-cover/ + __ https://pypi.org/project/diff-cover/ -- `cuvner`__ offers alternate visualizations of coverage data, including ones +* `cuvner`__ offers alternate visualizations of coverage data, including ones for use in terminals. -__ https://meejah.ca/projects/cuvner + __ https://meejah.ca/projects/cuvner -- `emacs-python-coverage`__ is an experimental Emacs package to report code +* `emacs-python-coverage`__ is an experimental Emacs package to report code coverage output produced by Python's coverage package directly inside Emacs buffers. -__ https://github.com/wbolster/emacs-python-coverage + __ https://github.com/wbolster/emacs-python-coverage -- `python-genbadge`__ provides a set of commandline utilities to generate badges for tools that do not provide one, +* `python-genbadge`__ provides a set of commandline utilities to generate badges for tools that do not provide one, including coverage badges. -__ https://smarie.github.io/python-genbadge/ + __ https://smarie.github.io/python-genbadge/ GitHub Action articles @@ -112,10 +112,10 @@ GitHub Action articles How to use GitHub Actions for reporting. -- `How to Ditch Codecov for Python Projects`__ +* `How to Ditch Codecov for Python Projects`__ -__ https://hynek.me/articles/ditch-codecov-python/ + __ https://hynek.me/articles/ditch-codecov-python/ -- `Making a coverage badge`__ +* `Making a coverage badge`__ -__ https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html + __ https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html From 95314ad9e492193e8b57ce378a731beb1212e222 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 3 Feb 2024 06:52:08 -0500 Subject: [PATCH 12/26] docs: more about other resources --- doc/other.rst | 24 +++++++++++++++++------- doc/plugins.rst | 26 ++------------------------ 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/doc/other.rst b/doc/other.rst index a53f634b2..d0998b37f 100644 --- a/doc/other.rst +++ b/doc/other.rst @@ -74,6 +74,11 @@ Coverage.py plugins to enable coverage measurement of other languages. __ https://github.com/timmartin/hy-coverage +* `coverage-mako-plugin`__ measures coverage in Mako templates. + Doesn't work yet, probably needs some changes in Mako itself. + + __ https://bitbucket-archive.softwareheritage.org/projects/ne/ned/coverage-mako-plugin.html + Reporting helpers ----------------- @@ -101,21 +106,26 @@ Helpers for seeing the results. __ https://github.com/wbolster/emacs-python-coverage -* `python-genbadge`__ provides a set of commandline utilities to generate badges for tools that do not provide one, - including coverage badges. +* `python-genbadge`__ provides a set of command line utilities to generate + badges for tools that do not provide one, including coverage badges. __ https://smarie.github.io/python-genbadge/ -GitHub Action articles ----------------------- +Other articles +-------------- -How to use GitHub Actions for reporting. +Writings about ways to enhance your use of coverage.py. -* `How to Ditch Codecov for Python Projects`__ +* `How to Ditch Codecov for Python Projects`__: using GitHub Actions to manage + coverage across versions and report on results. __ https://hynek.me/articles/ditch-codecov-python/ -* `Making a coverage badge`__ +* `Making a coverage badge`__: using GitHub Actions to produce a colored badge. __ https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html + +* `Coverage goals`__: a sidecar tool for reporting on per-file coverage goals. + + __ https://nedbatchelder.com/blog/202111/coverage_goals.html diff --git a/doc/plugins.rst b/doc/plugins.rst index 0bf3af935..7be4e4b6b 100644 --- a/doc/plugins.rst +++ b/doc/plugins.rst @@ -25,6 +25,8 @@ implementing coverage measurement for non-Python files. Information about using plug-ins is on this page. To write a plug-in, see :ref:`api_plugin`. +See :ref:`other` for available plug-ins. + .. versionadded:: 4.0 @@ -133,27 +135,3 @@ a coverage.py plug-in called ``something.plugin``. like "Plugin file tracers (something.plugin) aren't supported with PyTracer," then you don't have the :ref:`C extension ` installed. The C extension is needed for certain plug-ins. - - -Available plug-ins ------------------- - -Some coverage.py plug-ins you might find useful: - -* `Django template coverage.py plug-in`__: for measuring coverage in Django - templates. - - .. __: https://pypi.org/project/django_coverage_plugin/ - -* `Conditional coverage plug-in`__: for measuring coverage based - on any rules you define! - Can exclude different lines of code that are only executed - on different platforms, python versions, - and with different dependencies installed. - - .. __: https://github.com/wemake-services/coverage-conditional-plugin - -* `Mako template coverage plug-in`__: for measuring coverage in Mako templates. - Doesn't work yet, probably needs some changes in Mako itself. - - .. __: https://bitbucket-archive.softwareheritage.org/projects/ne/ned/coverage-mako-plugin.html From e68b37e022ca1935b7550ac0e22329c46ccb1372 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 3 Feb 2024 14:46:12 -0500 Subject: [PATCH 13/26] docs: note the --concurrency changes needed in 6.2. #1300 --- CHANGES.rst | 13 +++++++++---- doc/migrating.rst | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 98934427a..461f2af6c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,9 @@ These changes are listed in decreasing version number order. Note this can be different from a strict chronological order when there are two branches in development at the same time, such as 4.5.x and 5.0. +See :ref:`migrating` for significant changes that might be required when +upgrading your version of coverage.py. + .. When updating the "Unreleased" header to a specific version, use this .. format. Don't forget the jump target: .. @@ -892,10 +895,12 @@ Version 6.3 — 2022-01-25 Version 6.2 — 2021-11-26 ------------------------ -- Feature: Now the ``--concurrency`` setting can now have a list of values, so - that threads and another lightweight threading package can be measured - together, such as ``--concurrency=gevent,thread``. Closes `issue 1012`_ and - `issue 1082`_. +- Feature: Now the ``--concurrency`` setting can have a list of values, so that + threads and another lightweight threading package can be measured together, + such as ``--concurrency=gevent,thread``. Closes `issue 1012`_ and `issue + 1082`_. This also means that ``thread`` must be explicitly specified in some + cases that used to be implicit such as ``--concurrency=multiprocessing``, + which must be changed to ``--concurrency=multiprocessing,thread``. - Fix: A module specified as the ``source`` setting is imported during startup, before the user program imports it. This could cause problems if the rest of diff --git a/doc/migrating.rst b/doc/migrating.rst index 443afac63..865ede3a0 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -8,10 +8,10 @@ Migrating between versions ========================== New versions of coverage.py or Python might require you to adjust your -settings, options, or other aspects how you use coverage.py. This page details -those changes. +settings, options, or other aspects of how you use coverage.py. This page +details those changes. -.. _migrating_cov7: +.. _migrating_cov7x: Migrating to coverage.py 7.x ---------------------------- @@ -41,6 +41,18 @@ Consider these changes when migrating to coverage.py 7.x: updates. +.. _migrating_cov62: + +Migrating to coverage.py 6.2 +---------------------------- + +- The ``--concurrency`` settings changed in 6.2 to be a list of values. You + might need to explicitly list concurrency options that we previously implied. + For example, ``--concurrency=multiprocessing`` used to implicitly enable + thread concurrency. Now that must be explicitly enabled with + ``--concurrency=multiprocessing,thread``. + + .. _migrating_py312: Migrating to Python 3.12 From 383fa084a37305abb282e8f071791942a9ce5272 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 3 Feb 2024 15:04:44 -0500 Subject: [PATCH 14/26] build: when making github releases, update any that need updating --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 52a6c4cce..09f81672e 100644 --- a/Makefile +++ b/Makefile @@ -287,7 +287,7 @@ $(RELNOTES_JSON): $(CHANGES_MD) $(DOCBIN)/python ci/parse_relnotes.py tmp/rst_rst/changes.md $(RELNOTES_JSON) github_releases: $(DOCBIN) ## Update GitHub releases. - $(DOCBIN)/python -m scriv github-release + $(DOCBIN)/python -m scriv github-release --all comment_on_fixes: $(RELNOTES_JSON) ## Add a comment to issues that were fixed. python ci/comment_on_fixes.py $(REPO_OWNER) From d8ad9a06f405fa88c8ae8f542cfe6bb086440118 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 5 Feb 2024 13:35:38 -0500 Subject: [PATCH 15/26] docs: a template for support requests --- .github/ISSUE_TEMPLATE/support.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/support.md diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md new file mode 100644 index 000000000..d373ef5c6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support.md @@ -0,0 +1,26 @@ +--- +name: Support request +about: Ask for help using coverage.py +title: '' +labels: support, needs triage +assignees: '' + +--- + +**Have you asked elsewhere?** + +There are other good places to ask for help using coverage.py. These places let +other people suggest solutions, are more likely places for people to find your +question: + +- [Stack Overflow](https://stackoverflow.com/questions/tagged/coverage.py) +- [discuss.python.org](https://discuss.python.org/search?q=coverage.py) + +**Describe your situation** + +Wherever you ask your question, be sure to explain: + +- What you did +- What happened +- How that was different than what you wanted to happen +- What kind of help you need From 94feef010906b868be605c4fd411a044b2f265e8 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 10 Feb 2024 23:11:21 +0200 Subject: [PATCH 16/26] build: only push to report repo and create badge for upstream (#1748) --- .github/workflows/coverage.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2cdbd9ded..5c63d1d4a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -235,7 +235,9 @@ jobs: path: reports_repo/${{ env.report_dir }} - name: "Push to report repo" - if: ${{ github.ref == 'refs/heads/master' }} + if: | + github.repository_owner == 'nedbat' + && github.ref == 'refs/heads/master' env: COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: | @@ -259,7 +261,9 @@ jobs: echo '[${{ env.url }}](${{ env.url }})' >> $GITHUB_STEP_SUMMARY - name: "Create badge" - if: ${{ github.ref == 'refs/heads/master' }} + if: | + github.repository_owner == 'nedbat' + && github.ref == 'refs/heads/master' # https://gist.githubusercontent.com/nedbat/8c6980f77988a327348f9b02bbaf67f5 uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 with: From 841205461a91da63409ac6e134db9f4ef870fae4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 14 Feb 2024 06:59:34 -0500 Subject: [PATCH 17/26] chore: make upgrade --- requirements/dev.pip | 23 +++++++++++++---------- requirements/kit.pip | 11 ++++++----- requirements/light-threads.pip | 6 +++--- requirements/mypy.pip | 2 +- requirements/pip-tools.pip | 4 ++-- requirements/pip.pip | 6 +++--- requirements/pytest.pip | 2 +- requirements/tox.pip | 2 +- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/requirements/dev.pip b/requirements/dev.pip index be4d627dd..c842b00e3 100644 --- a/requirements/dev.pip +++ b/requirements/dev.pip @@ -4,7 +4,7 @@ # # make upgrade # -astroid==3.0.2 +astroid==3.0.3 # via pylint attrs==23.2.0 # via hypothesis @@ -12,7 +12,7 @@ build==1.0.3 # via check-manifest cachetools==5.3.2 # via tox -certifi==2023.11.17 +certifi==2024.2.2 # via requests chardet==5.2.0 # via tox @@ -47,7 +47,7 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==3.0.3 # via -r requirements/dev.in -hypothesis==6.97.1 +hypothesis==6.98.4 # via -r requirements/pytest.in idna==3.6 # via requests @@ -62,7 +62,7 @@ iniconfig==2.0.0 # via pytest isort==5.13.2 # via pylint -jaraco-classes==3.3.0 +jaraco-classes==3.3.1 # via keyring jedi==0.19.1 # via pudb @@ -91,7 +91,7 @@ parso==0.8.3 # via jedi pkginfo==1.9.6 # via twine -platformdirs==4.1.0 +platformdirs==4.2.0 # via # pylint # tox @@ -156,18 +156,19 @@ tox==4.12.1 # tox-gh tox-gh==1.3.1 # via -r requirements/tox.in -twine==4.0.2 +twine==5.0.0 # via -r requirements/dev.in typing-extensions==4.9.0 # via # astroid # pylint # rich -urllib3==2.1.0 + # urwid +urllib3==2.2.0 # via # requests # twine -urwid==2.4.6 +urwid==2.5.3 # via # pudb # urwid-readline @@ -177,15 +178,17 @@ virtualenv==20.25.0 # via # -r requirements/pip.in # tox +wcwidth==0.2.13 + # via urwid zipp==3.17.0 # via # importlib-metadata # importlib-resources # The following packages are considered to be unsafe in a requirements file: -pip==23.3.2 +pip==24.0 # via -r requirements/pip.in -setuptools==69.0.3 +setuptools==69.1.0 # via # -r requirements/pip.in # check-manifest diff --git a/requirements/kit.pip b/requirements/kit.pip index 5d4fcd70d..6178060c8 100644 --- a/requirements/kit.pip +++ b/requirements/kit.pip @@ -4,7 +4,7 @@ # # make upgrade # -auditwheel==5.4.0 +auditwheel==6.0.0 # via -r requirements/kit.in bashlex==0.18 # via cibuildwheel @@ -12,9 +12,9 @@ bracex==2.4 # via cibuildwheel build==1.0.3 # via -r requirements/kit.in -certifi==2023.11.17 +certifi==2024.2.2 # via cibuildwheel -cibuildwheel==2.16.3 +cibuildwheel==2.16.5 # via -r requirements/kit.in colorama==0.4.6 # via -r requirements/kit.in @@ -24,9 +24,10 @@ importlib-metadata==7.0.1 # via build packaging==23.2 # via + # auditwheel # build # cibuildwheel -platformdirs==4.1.0 +platformdirs==4.2.0 # via cibuildwheel pyelftools==0.30 # via auditwheel @@ -45,5 +46,5 @@ zipp==3.17.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -setuptools==69.0.3 +setuptools==69.1.0 # via -r requirements/kit.in diff --git a/requirements/light-threads.pip b/requirements/light-threads.pip index 495aa3192..4c31d6470 100644 --- a/requirements/light-threads.pip +++ b/requirements/light-threads.pip @@ -8,9 +8,9 @@ cffi==1.16.0 # via -r requirements/light-threads.in dnspython==2.5.0 # via eventlet -eventlet==0.35.0 +eventlet==0.35.1 # via -r requirements/light-threads.in -gevent==23.9.1 +gevent==24.2.1 # via -r requirements/light-threads.in greenlet==3.0.3 # via @@ -25,7 +25,7 @@ zope-interface==6.1 # via gevent # The following packages are considered to be unsafe in a requirements file: -setuptools==69.0.3 +setuptools==69.1.0 # via # zope-event # zope-interface diff --git a/requirements/mypy.pip b/requirements/mypy.pip index 5b8c07e29..18266c880 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -16,7 +16,7 @@ execnet==2.0.2 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.97.1 +hypothesis==6.98.4 # via -r requirements/pytest.in iniconfig==2.0.0 # via pytest diff --git a/requirements/pip-tools.pip b/requirements/pip-tools.pip index d73ab3c9f..52b3fd73d 100644 --- a/requirements/pip-tools.pip +++ b/requirements/pip-tools.pip @@ -27,7 +27,7 @@ zipp==3.17.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -pip==23.3.2 +pip==24.0 # via pip-tools -setuptools==69.0.3 +setuptools==69.1.0 # via pip-tools diff --git a/requirements/pip.pip b/requirements/pip.pip index d1830e6ed..3e3a6362b 100644 --- a/requirements/pip.pip +++ b/requirements/pip.pip @@ -8,13 +8,13 @@ distlib==0.3.8 # via virtualenv filelock==3.13.1 # via virtualenv -platformdirs==4.1.0 +platformdirs==4.2.0 # via virtualenv virtualenv==20.25.0 # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==23.3.2 +pip==24.0 # via -r requirements/pip.in -setuptools==69.0.3 +setuptools==69.1.0 # via -r requirements/pip.in diff --git a/requirements/pytest.pip b/requirements/pytest.pip index 5e20c7f42..d38dc2839 100644 --- a/requirements/pytest.pip +++ b/requirements/pytest.pip @@ -16,7 +16,7 @@ execnet==2.0.2 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.97.1 +hypothesis==6.98.4 # via -r requirements/pytest.in iniconfig==2.0.0 # via pytest diff --git a/requirements/tox.pip b/requirements/tox.pip index 874cc77fd..7f449c1b9 100644 --- a/requirements/tox.pip +++ b/requirements/tox.pip @@ -22,7 +22,7 @@ packaging==23.2 # via # pyproject-api # tox -platformdirs==4.1.0 +platformdirs==4.2.0 # via # tox # virtualenv From 628c1c5ec1b481eaf6f2013461da8bbe9de41576 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 14 Feb 2024 15:19:32 -0500 Subject: [PATCH 18/26] fix: avoid a dict-changed-size error Windows 3.12 failed occasionally with this error: ``` @panopticon() def stop(self) -> None: """Stop this Tracer.""" if not self.sysmon_on: # In forking situations, we might try to stop when we are not # started. Do nothing in that case. return assert sys_monitoring is not None sys_monitoring.set_events(self.myid, 0) > for code in self.local_event_codes.values(): E RuntimeError: dictionary changed size during iteration ``` By setting self.sysmon_on=False before iteration, we lessen the chance of adding an item to the dict during the iteration. --- coverage/sysmon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage/sysmon.py b/coverage/sysmon.py index ab231fde1..e6fe28fc3 100644 --- a/coverage/sysmon.py +++ b/coverage/sysmon.py @@ -251,11 +251,11 @@ def stop(self) -> None: return assert sys_monitoring is not None sys_monitoring.set_events(self.myid, 0) + self.sysmon_on = False for code in self.local_event_codes.values(): sys_monitoring.set_local_events(self.myid, code, 0) self.local_event_codes = {} sys_monitoring.free_tool_id(self.myid) - self.sysmon_on = False @panopticon() def post_fork(self) -> None: From 575a44c350bb8165185e6594421443189f904ce6 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:15:11 +0200 Subject: [PATCH 19/26] build: temporarily pin to 3.13.0a3 for Windows (#1751) --- .github/workflows/coverage.yml | 7 +++++++ .github/workflows/testsuite.yml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5c63d1d4a..5c9a8814f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -69,6 +69,13 @@ jobs: python-version: "pypy-3.9" - os: windows python-version: "pypy-3.10" + # Skip 3.13.0a4 and pin to 3.13.0a3 for Windows due to build error. + # Undo when 3.13.0a5 is released. + - os: windows + python-version: "3.13" + include: + - os: windows + python-version: "3.13.0-alpha.3" # If one job fails, stop the whole thing. fail-fast: true diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index e6742753e..ee94b1ea0 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -62,6 +62,13 @@ jobs: python-version: "pypy-3.9" - os: windows python-version: "pypy-3.10" + # Skip 3.13.0a4 and pin to 3.13.0a3 for Windows due to build error. + # Undo when 3.13.0a5 is released. + - os: windows + python-version: "3.13" + include: + - os: windows + python-version: "3.13.0-alpha.3" fail-fast: false steps: From 8b0e0398983592f4a432b656910d67aa5d14021d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:48:45 +0200 Subject: [PATCH 20/26] fix: only use "sysmon" core when available (Python 3.12+) (#1747) * Only use sysmon core when available (Python 3.12+) * Update test case for both with and without SysMonitor --- coverage/collector.py | 4 ++++ tests/test_process.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/coverage/collector.py b/coverage/collector.py index 1fd06dbb5..65e329822 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -150,6 +150,10 @@ def __init__( core = "pytrace" else: core = os.getenv("COVERAGE_CORE") + + if core == "sysmon" and not env.PYBEHAVIOR.pep669: + core = None + if not core: # Once we're comfortable with sysmon as a default: # if env.PYBEHAVIOR.pep669 and self.should_start_context is None: diff --git a/tests/test_process.py b/tests/test_process.py index 5aeb49744..8146e0d17 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1122,7 +1122,6 @@ def test_core_request_pytrace(self) -> None: core = re_line(r" core:", out).strip() assert core == "core: PyTracer" - @pytest.mark.skipif(not env.PYBEHAVIOR.pep669, reason="No sys.monitoring to request") def test_core_request_sysmon(self) -> None: self.del_environ("COVERAGE_TEST_CORES") self.set_environ("COVERAGE_CORE", "sysmon") @@ -1130,7 +1129,10 @@ def test_core_request_sysmon(self) -> None: out = self.run_command("coverage run --debug=sys numbers.py") assert out.endswith("123 456\n") core = re_line(r" core:", out).strip() - assert core == "core: SysMonitor" + if env.PYBEHAVIOR.pep669: + assert core == "core: SysMonitor" + else: + assert core in ("core: CTracer", "core: PyTracer") class FailUnderNoFilesTest(CoverageTest): From c56c3a200386217b6ff598c587853ebd8b8128e6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 20 Feb 2024 07:58:05 -0500 Subject: [PATCH 21/26] fix: issue a warning if we can't use sysmon as requested. --- CHANGES.rst | 6 +++++- coverage/collector.py | 1 + doc/cmd.rst | 5 +++++ tests/test_process.py | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 461f2af6c..fd26bc0f6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -23,7 +23,11 @@ upgrading your version of coverage.py. Unreleased ---------- -Nothing yet. +- Fix: setting ``COVERAGE_CORE=sysmon`` no longer errors on 3.11 and lower, + thanks `Hugo van Kemenade `_. It now issues a warning that + sys.monitoring is not available and falls back to the default core instead. + +.. _pull 1747: https://github.com/nedbat/coveragepy/pull/1747 .. scriv-start-here diff --git a/coverage/collector.py b/coverage/collector.py index 65e329822..87cd620e3 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -152,6 +152,7 @@ def __init__( core = os.getenv("COVERAGE_CORE") if core == "sysmon" and not env.PYBEHAVIOR.pep669: + self.warn("sys.monitoring isn't available, using default core", slug="no-sysmon") core = None if not core: diff --git a/doc/cmd.rst b/doc/cmd.rst index a440e987c..439927d9c 100644 --- a/doc/cmd.rst +++ b/doc/cmd.rst @@ -273,6 +273,11 @@ Conflicting dynamic contexts (dynamic-conflict) :meth:`.Coverage.switch_context` function to change the context. Only one of these mechanisms should be in use at a time. +sys.monitoring isn't available, using default core (no-sysmon) + You requested to use the sys.monitoring measurement core, but are running on + Python 3.11 or lower where it isn't available. A default core will be used + instead. + Individual warnings can be disabled with the :ref:`disable_warnings ` configuration setting. To silence "No data was collected," add this to your configuration file: diff --git a/tests/test_process.py b/tests/test_process.py index 8146e0d17..43518066e 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1129,10 +1129,13 @@ def test_core_request_sysmon(self) -> None: out = self.run_command("coverage run --debug=sys numbers.py") assert out.endswith("123 456\n") core = re_line(r" core:", out).strip() + warns = re_lines(r"CoverageWarning: sys.monitoring isn't available", out) if env.PYBEHAVIOR.pep669: assert core == "core: SysMonitor" + assert not warns else: assert core in ("core: CTracer", "core: PyTracer") + assert warns class FailUnderNoFilesTest(CoverageTest): From d365814bc8e6911d243f2f35e7b1f1dbd40803ef Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 20 Feb 2024 06:54:41 -0500 Subject: [PATCH 22/26] chore: make upgrade --- requirements/dev.pip | 10 +++++----- requirements/light-threads.pip | 4 ++-- requirements/mypy.pip | 4 ++-- requirements/pip-tools.pip | 6 ++++-- requirements/pytest.pip | 4 ++-- requirements/tox.pip | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/requirements/dev.pip b/requirements/dev.pip index c842b00e3..195904cf8 100644 --- a/requirements/dev.pip +++ b/requirements/dev.pip @@ -47,7 +47,7 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==3.0.3 # via -r requirements/dev.in -hypothesis==6.98.4 +hypothesis==6.98.9 # via -r requirements/pytest.in idna==3.6 # via requests @@ -114,7 +114,7 @@ pyproject-api==1.6.1 # via tox pyproject-hooks==1.0.0 # via build -pytest==8.0.0 +pytest==8.0.1 # via # -r requirements/pytest.in # pytest-xdist @@ -150,7 +150,7 @@ tomli==2.0.1 # tox tomlkit==0.12.3 # via pylint -tox==4.12.1 +tox==4.13.0 # via # -r requirements/tox.in # tox-gh @@ -164,11 +164,11 @@ typing-extensions==4.9.0 # pylint # rich # urwid -urllib3==2.2.0 +urllib3==2.2.1 # via # requests # twine -urwid==2.5.3 +urwid==2.6.1 # via # pudb # urwid-readline diff --git a/requirements/light-threads.pip b/requirements/light-threads.pip index 4c31d6470..25e58cb4f 100644 --- a/requirements/light-threads.pip +++ b/requirements/light-threads.pip @@ -6,7 +6,7 @@ # cffi==1.16.0 # via -r requirements/light-threads.in -dnspython==2.5.0 +dnspython==2.6.1 # via eventlet eventlet==0.35.1 # via -r requirements/light-threads.in @@ -21,7 +21,7 @@ pycparser==2.21 # via cffi zope-event==5.0 # via gevent -zope-interface==6.1 +zope-interface==6.2 # via gevent # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/mypy.pip b/requirements/mypy.pip index 18266c880..8263a95b6 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -16,7 +16,7 @@ execnet==2.0.2 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.98.4 +hypothesis==6.98.9 # via -r requirements/pytest.in iniconfig==2.0.0 # via pytest @@ -30,7 +30,7 @@ pluggy==1.4.0 # via pytest pygments==2.17.2 # via -r requirements/pytest.in -pytest==8.0.0 +pytest==8.0.1 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/pip-tools.pip b/requirements/pip-tools.pip index 52b3fd73d..e18ace330 100644 --- a/requirements/pip-tools.pip +++ b/requirements/pip-tools.pip @@ -12,10 +12,12 @@ importlib-metadata==7.0.1 # via build packaging==23.2 # via build -pip-tools==7.3.0 +pip-tools==7.4.0 # via -r requirements/pip-tools.in pyproject-hooks==1.0.0 - # via build + # via + # build + # pip-tools tomli==2.0.1 # via # build diff --git a/requirements/pytest.pip b/requirements/pytest.pip index d38dc2839..502c0497a 100644 --- a/requirements/pytest.pip +++ b/requirements/pytest.pip @@ -16,7 +16,7 @@ execnet==2.0.2 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.98.4 +hypothesis==6.98.9 # via -r requirements/pytest.in iniconfig==2.0.0 # via pytest @@ -26,7 +26,7 @@ pluggy==1.4.0 # via pytest pygments==2.17.2 # via -r requirements/pytest.in -pytest==8.0.0 +pytest==8.0.1 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/tox.pip b/requirements/tox.pip index 7f449c1b9..3e1dce2c6 100644 --- a/requirements/tox.pip +++ b/requirements/tox.pip @@ -34,7 +34,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.12.1 +tox==4.13.0 # via # -r requirements/tox.in # tox-gh From a7d10222110c37ecd4f10f4f752ddc62024630a7 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 20 Feb 2024 12:41:34 -0500 Subject: [PATCH 23/26] build: some Makefile targets only make sense from the release steps --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 09f81672e..cf81a8a38 100644 --- a/Makefile +++ b/Makefile @@ -179,19 +179,19 @@ sample_html_beta: _sample_cog_html ## Generate sample HTML report for a beta rel REPO_OWNER = nedbat/coveragepy -edit_for_release: ## Edit sources to insert release facts. +edit_for_release: #: Edit sources to insert release facts (see howto.txt). python igor.py edit_for_release cheats: ## Create some useful snippets for releasing. python igor.py cheats | tee cheats.txt -relbranch: ## Create the branch for releasing. +relbranch: #: Create the branch for releasing (see howto.txt). git switch -c nedbat/release-$$(date +%Y%m%d) -relcommit1: ## Commit the first release changes. +relcommit1: #: Commit the first release changes (see howto.txt). git commit -am "docs: prep for $$(python setup.py --version)" -relcommit2: ## Commit the latest sample HTML report. +relcommit2: #: Commit the latest sample HTML report (see howto.txt). git commit -am "docs: sample HTML for $$(python setup.py --version)" kit: ## Make the source distribution. From 026dca7d7e8591614ec035fe9f05a87808892686 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 20 Feb 2024 12:43:37 -0500 Subject: [PATCH 24/26] docs: prep for 7.4.2 --- CHANGES.rst | 10 ++++++---- coverage/version.py | 4 ++-- doc/conf.py | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index fd26bc0f6..933aac7d8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,8 +20,12 @@ upgrading your version of coverage.py. .. Version 9.8.1 — 2027-07-27 .. -------------------------- -Unreleased ----------- +.. scriv-start-here + +.. _changes_7-4-2: + +Version 7.4.2 — 2024-02-20 +-------------------------- - Fix: setting ``COVERAGE_CORE=sysmon`` no longer errors on 3.11 and lower, thanks `Hugo van Kemenade `_. It now issues a warning that @@ -30,8 +34,6 @@ Unreleased .. _pull 1747: https://github.com/nedbat/coveragepy/pull/1747 -.. scriv-start-here - .. _changes_7-4-1: Version 7.4.1 — 2024-01-26 diff --git a/coverage/version.py b/coverage/version.py index 1aef04bd6..69fe7597e 100644 --- a/coverage/version.py +++ b/coverage/version.py @@ -8,8 +8,8 @@ # version_info: same semantics as sys.version_info. # _dev: the .devN suffix if any. -version_info = (7, 4, 2, "alpha", 0) -_dev = 1 +version_info = (7, 4, 2, "final", 0) +_dev = 0 def _make_version( diff --git a/doc/conf.py b/doc/conf.py index 04ce4c0a6..18c5a3c70 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -67,11 +67,11 @@ # @@@ editable copyright = "2009–2024, Ned Batchelder" # pylint: disable=redefined-builtin # The short X.Y.Z version. -version = "7.4.1" +version = "7.4.2" # The full version, including alpha/beta/rc tags. -release = "7.4.1" +release = "7.4.2" # The date of release, in "monthname day, year" format. -release_date = "January 26, 2024" +release_date = "February 20, 2024" # @@@ end rst_epilog = """ From 65d686c8eb76ef897291af898d53dee55c57f349 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 20 Feb 2024 12:44:07 -0500 Subject: [PATCH 25/26] docs: sample HTML for 7.4.2 --- doc/sample_html/d_7b071bdc2a35fa80___init___py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80___main___py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_cogapp_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_makefiles_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_test_cogapp_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_test_makefiles_py.html | 8 ++++---- .../d_7b071bdc2a35fa80_test_whiteutils_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_utils_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html | 8 ++++---- doc/sample_html/index.html | 8 ++++---- doc/sample_html/status.json | 2 +- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html index f6a0e5eef..6457bf694 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html @@ -66,8 +66,8 @@

^ index     » next       - coverage.py v7.4.1, - created at 2024-01-26 09:16 -0500 + coverage.py v7.4.2, + created at 2024-02-20 12:43 -0500