Skip to content

Commit

Permalink
Merge branch 'master' into suppress-path0
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored May 3, 2024
2 parents 17d2ff8 + fdc0ee8 commit c2a67eb
Show file tree
Hide file tree
Showing 144 changed files with 9,657 additions and 1,787 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ concurrency:
jobs:
coverage:
name: "${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"
runs-on: "${{ matrix.os }}-${{ matrix.os-version || 'latest' }}"
env:
MATRIX_ID: "${{ matrix.python-version }}.${{ matrix.os }}"

Expand Down Expand Up @@ -69,6 +69,13 @@ jobs:
python-version: "pypy-3.9"
- os: windows
python-version: "pypy-3.10"
# If we need to tweak the os version we can do it with an include like
# this:
# include:
# - python-version: "3.8"
# os: "macos"
# os-version: "13"

# If one job fails, stop the whole thing.
fail-fast: true

Expand Down
28 changes: 15 additions & 13 deletions .github/workflows/kit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ concurrency:
jobs:
wheels:
name: "${{ matrix.py }} ${{ matrix.os }} ${{ matrix.arch }} wheels"
runs-on: ${{ matrix.os }}-latest
runs-on: "${{ matrix.os }}-${{ matrix.os-version || 'latest' }}"
env:
MATRIX_ID: "${{ matrix.py }}-${{ matrix.os }}-${{ matrix.arch }}"
strategy:
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
#
# # Some OS/arch combinations need overrides for the Python versions:
# os_arch_pys = {
# ("macos", "arm64"): ["cp38", "cp39", "cp310", "cp311", "cp312"],
# # ("macos", "arm64"): ["cp38", "cp39", "cp310", "cp311", "cp312"],
# }
#
# #----- ^^^ ---------------------- ^^^ -----
Expand All @@ -98,6 +98,8 @@ jobs:
# "py": the_py,
# "arch": the_arch,
# }
# if the_os == "macos":
# them["os-version"] = "13"
# print(f"- {json.dumps(them)}")
# ]]]
- {"os": "ubuntu", "py": "cp38", "arch": "x86_64"}
Expand All @@ -115,16 +117,16 @@ jobs:
- {"os": "ubuntu", "py": "cp310", "arch": "aarch64"}
- {"os": "ubuntu", "py": "cp311", "arch": "aarch64"}
- {"os": "ubuntu", "py": "cp312", "arch": "aarch64"}
- {"os": "macos", "py": "cp38", "arch": "arm64"}
- {"os": "macos", "py": "cp39", "arch": "arm64"}
- {"os": "macos", "py": "cp310", "arch": "arm64"}
- {"os": "macos", "py": "cp311", "arch": "arm64"}
- {"os": "macos", "py": "cp312", "arch": "arm64"}
- {"os": "macos", "py": "cp38", "arch": "x86_64"}
- {"os": "macos", "py": "cp39", "arch": "x86_64"}
- {"os": "macos", "py": "cp310", "arch": "x86_64"}
- {"os": "macos", "py": "cp311", "arch": "x86_64"}
- {"os": "macos", "py": "cp312", "arch": "x86_64"}
- {"os": "macos", "py": "cp38", "arch": "arm64", "os-version": "13"}
- {"os": "macos", "py": "cp39", "arch": "arm64", "os-version": "13"}
- {"os": "macos", "py": "cp310", "arch": "arm64", "os-version": "13"}
- {"os": "macos", "py": "cp311", "arch": "arm64", "os-version": "13"}
- {"os": "macos", "py": "cp312", "arch": "arm64", "os-version": "13"}
- {"os": "macos", "py": "cp38", "arch": "x86_64", "os-version": "13"}
- {"os": "macos", "py": "cp39", "arch": "x86_64", "os-version": "13"}
- {"os": "macos", "py": "cp310", "arch": "x86_64", "os-version": "13"}
- {"os": "macos", "py": "cp311", "arch": "x86_64", "os-version": "13"}
- {"os": "macos", "py": "cp312", "arch": "x86_64", "os-version": "13"}
- {"os": "windows", "py": "cp38", "arch": "x86"}
- {"os": "windows", "py": "cp39", "arch": "x86"}
- {"os": "windows", "py": "cp310", "arch": "x86"}
Expand All @@ -135,7 +137,7 @@ jobs:
- {"os": "windows", "py": "cp310", "arch": "AMD64"}
- {"os": "windows", "py": "cp311", "arch": "AMD64"}
- {"os": "windows", "py": "cp312", "arch": "AMD64"}
# [[[end]]] (checksum: a6ca53e9c620c9e5ca85e7322122056c)
# [[[end]]] (checksum: 16ed28c185d540b2d9972a0217864472)
fail-fast: false

steps:
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/python-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,41 @@ concurrency:

jobs:
tests:
name: "${{ matrix.python-version }}"
# Choose a recent Ubuntu that deadsnakes still builds all the versions for.
# For example, deadsnakes doesn't provide 3.10 nightly for 22.04 (jammy)
# because jammy ships 3.10, and deadsnakes doesn't want to clobber it.
# https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly/+packages
# https://github.com/deadsnakes/issues/issues/234
# bionic: 18, focal: 20, jammy: 22
runs-on: ubuntu-20.04
name: "${{ matrix.python-version }} on ${{ matrix.os-short }}"
runs-on: "${{ matrix.os }}"
# If it doesn't finish in an hour, it's not going to. Don't spin for six
# hours needlessly.
timeout-minutes: 60

strategy:
matrix:
os:
# Choose a recent Ubuntu that deadsnakes still builds all the versions for.
# For example, deadsnakes doesn't provide 3.10 nightly for 22.04 (jammy)
# because jammy ships 3.10, and deadsnakes doesn't want to clobber it.
# https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly/+packages
# https://github.com/deadsnakes/issues/issues/234
# See https://github.com/deadsnakes/nightly for the source of the nightly
# builds.
# bionic: 18, focal: 20, jammy: 22, noble: 24
- "ubuntu-22.04"
os-short:
- "ubuntu"
python-version:
# When changing this list, be sure to check the [gh] list in
# tox.ini so that tox will run properly. PYVERSIONS
# Available versions:
# https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly/+packages
- "3.11-dev"
- "3.12-dev"
- "3.13-dev"
# https://github.com/actions/setup-python#available-versions-of-pypy
- "pypy-3.8-nightly"
- "pypy-3.9-nightly"
- "pypy-3.10-nightly"
include:
- python-version: "pypy-3.10-nightly"
os: "windows-latest"
os-short: "windows"
fail-fast: false

steps:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
# Because pylint can report different things on different OS's (!)
# (https://github.com/PyCQA/pylint/issues/3489), run this on Mac where local
# pylint gets run.
runs-on: macos-latest
# GitHub is rolling out macos 14, but it doesn't have Python 3.8 or 3.9.
# https://mastodon.social/@hugovk/112320493602782374
runs-on: macos-13

steps:
- name: "Check out the repo"
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ concurrency:
jobs:
tests:
name: "${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"
runs-on: "${{ matrix.os }}-${{ matrix.os-version || 'latest' }}"
# Don't run tests if the branch name includes "-notests"
if: "!contains(github.ref, '-notests')"
strategy:
Expand All @@ -57,11 +57,19 @@ jobs:
exclude:
# 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.
# skip them for now. These excludes can be removed once GitHub uses
# PyPy 7.3.16 on Windows. https://github.com/pypy/pypy/issues/4876
- os: windows
python-version: "pypy-3.9"
- os: windows
python-version: "pypy-3.10"
# If we need to tweak the os version we can do it with an include like
# this:
# include:
# - python-version: "3.8"
# os: "macos"
# os-version: "13"

fail-fast: false

steps:
Expand Down
54 changes: 52 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,65 @@ Unreleased

- Fix: the PYTHONSAFEPATH environment variable new in Python 3.11 is properly
supported, closing `issue 1696`_. Thanks, `Philipp A. <pull 1700_>`_.
- Fix: a pragma comment on the continuation lines of a multi-line statement
now excludes the statement and its body, the same as if the pragma is
on the first line. This closes `issue 754`_. The fix was contributed by
`Daniel Diniz <pull 1773_>`_.

- HTML report improvements:

- Support files (JavaScript and CSS) referenced by the HTML report now have
hashes added to their names to ensure updated files are used instead of
stale cached copies.

- Missing branch coverage explanations that said "the condition was never
false" now read "the condition was always true" because it's easier to
understand.

- Column sort order is remembered better as you move between the index pages,
fixing `issue 1766`_. Thanks, `Daniel Diniz <pull 1768_>`_.

.. _issue 754: https://github.com/nedbat/coveragepy/issues/754
.. _issue 1766: https://github.com/nedbat/coveragepy/issues/1766
.. _pull 1768: https://github.com/nedbat/coveragepy/pull/1768
.. _pull 1773: https://github.com/nedbat/coveragepy/pull/1773


.. scriv-start-here
.. _changes_7-5-0:

Version 7.5.0 — 2024-04-23
--------------------------

- Added initial support for function and class reporting in the HTML report.
There are now three index pages which link to each other: files, functions,
and classes. Other reports don't yet have this information, but it will be
added in the future where it makes sense. Feedback gladly accepted!
Finishes `issue 780`_.

- Other HTML report improvements:

- There is now a "hide covered" checkbox to filter out 100% files, finishing
`issue 1384`_.

- The index page is always sorted by one of its columns, with clearer
indications of the sorting.

- The "previous file" shortcut key didn't work on the index page, but now it
does, fixing `issue 1765`_.

- The debug output showing which configuration files were tried now shows
absolute paths to help diagnose problems where settings aren't taking effect,
and is renamed from "attempted_config_files" to the more logical
"config_files_attempted."

- Python 3.13.0a5 is supported.
- Python 3.13.0a6 is supported.

.. _issue 780: https://github.com/nedbat/coveragepy/issues/780
.. _issue 1384: https://github.com/nedbat/coveragepy/issues/1384
.. _issue 1765: https://github.com/nedbat/coveragepy/issues/1765

.. scriv-start-here

.. _changes_7-4-4:

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Dan Hemberger
Dan Riti
Dan Wandschneider
Danek Duvall
Daniel Diniz
Daniel Hahler
Danny Allen
David Christian
Expand Down Expand Up @@ -102,6 +103,7 @@ J. M. F. Tsang
JT Olds
Jacqueline Lee
Jakub Wilk
James Valleroy
Jan Rusak
Janakarajan Natarajan
Jerin Peter George
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

##@ Utilities

.PHONY: help clean_platform clean sterile
.PHONY: help clean_platform clean sterile install

help: ## Show this help.
@# Adapted from https://www.thapaliya.com/en/writings/well-documented-makefiles/
Expand Down Expand Up @@ -50,6 +50,9 @@ sterile: clean ## Remove all non-controlled content, even if expensive.
rm -rf .tox
rm -f cheats.txt

install: ## Install the developer tools
python3 -m pip install -r requirements/dev.pip


##@ Tests and quality checks

Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Coverage.py runs on these versions of Python:

.. PYVERSIONS
* Python 3.8 through 3.12, and 3.13.0a3 and up.
* Python 3.8 through 3.12, and 3.13.0a6 and up.
* PyPy3 versions 3.8 through 3.10.

Documentation is on `Read the Docs`_. Code repository and issue tracker are on
Expand All @@ -35,6 +35,7 @@ Documentation is on `Read the Docs`_. Code repository and issue tracker are on
.. _GitHub: https://github.com/nedbat/coveragepy

**New in 7.x:**
initial function/class reporting;
experimental support for sys.monitoring;
dropped support for Python 3.7;
added ``Coverage.collect()`` context manager;
Expand Down
5 changes: 1 addition & 4 deletions coverage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@
from coverage.data import CoverageData as CoverageData
from coverage.exceptions import CoverageException as CoverageException
from coverage.plugin import (
CodeRegion as CodeRegion,
CoveragePlugin as CoveragePlugin,
FileReporter as FileReporter,
FileTracer as FileTracer,
)

# Backward compatibility.
coverage = Coverage

# On Windows, we encode and decode deep enough that something goes wrong and
# the encodings.utf_8 module is loaded and then unloaded, I don't know why.
# Adding a reference here prevents it from being unloaded. Yuk.
4 changes: 2 additions & 2 deletions coverage/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from coverage.debug import info_header, short_stack, write_formatted_info
from coverage.exceptions import _BaseCoverageException, _ExceptionDuringRun, NoSource
from coverage.execfile import PyRunner
from coverage.results import Numbers, should_fail_under
from coverage.results import display_covered, should_fail_under
from coverage.version import __url__

# When adding to this file, alphabetization is important. Look for
Expand Down Expand Up @@ -760,7 +760,7 @@ def command_line(self, argv: list[str]) -> int:
precision = cast(int, self.coverage.get_option("report:precision"))
if should_fail_under(total, fail_under, precision):
msg = "total of {total} is less than fail-under={fail_under:.{p}f}".format(
total=Numbers(precision=precision).display_covered(total),
total=display_covered(total, precision),
fail_under=fail_under,
p=precision,
)
Expand Down
32 changes: 13 additions & 19 deletions coverage/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from coverage.python import PythonFileReporter
from coverage.report import SummaryReporter
from coverage.report_core import render_report
from coverage.results import Analysis
from coverage.results import Analysis, analysis_from_file_reporter
from coverage.types import (
FilePath, TConfigurable, TConfigSectionIn, TConfigValueIn, TConfigValueOut,
TFileDisposition, TLineNo, TMorf,
Expand Down Expand Up @@ -931,23 +931,15 @@ def analysis2(
analysis.missing_formatted(),
)

def _analyze(self, it: FileReporter | TMorf) -> Analysis:
"""Analyze a single morf or code unit.
Returns an `Analysis` object.
"""
# All reporting comes through here, so do reporting initialization.
def _analyze(self, morf: TMorf) -> Analysis:
"""Analyze a module or file. Private for now."""
self._init()
self._post_init()

data = self.get_data()
if isinstance(it, FileReporter):
fr = it
else:
fr = self._get_file_reporter(it)

return Analysis(data, self.config.precision, fr, self._file_mapper)
file_reporter = self._get_file_reporter(morf)
filename = self._file_mapper(file_reporter.filename)
return analysis_from_file_reporter(data, self.config.precision, file_reporter, filename)

@functools.lru_cache(maxsize=1)
def _get_file_reporter(self, morf: TMorf) -> FileReporter:
Expand Down Expand Up @@ -977,11 +969,14 @@ def _get_file_reporter(self, morf: TMorf) -> FileReporter:
assert isinstance(file_reporter, FileReporter)
return file_reporter

def _get_file_reporters(self, morfs: Iterable[TMorf] | None = None) -> list[FileReporter]:
"""Get a list of FileReporters for a list of modules or file names.
def _get_file_reporters(
self,
morfs: Iterable[TMorf] | None = None,
) -> list[tuple[FileReporter, TMorf]]:
"""Get FileReporters for a list of modules or file names.
For each module or file name in `morfs`, find a FileReporter. Return
the list of FileReporters.
a list pairing FileReporters with the morfs.
If `morfs` is a single module or file name, this returns a list of one
FileReporter. If `morfs` is empty or None, then the list of all files
Expand All @@ -996,8 +991,7 @@ def _get_file_reporters(self, morfs: Iterable[TMorf] | None = None) -> list[File
if not isinstance(morfs, (list, tuple, set)):
morfs = [morfs] # type: ignore[list-item]

file_reporters = [self._get_file_reporter(morf) for morf in morfs]
return file_reporters
return [(self._get_file_reporter(morf), morf) for morf in morfs]

def _prepare_data_for_reporting(self) -> None:
"""Re-map data before reporting, to get implicit "combine" behavior."""
Expand Down
Loading

0 comments on commit c2a67eb

Please sign in to comment.