From 7078342175ec5ddd1480794ebd10753cf83048dc Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 10:37:23 +0200 Subject: [PATCH 01/13] Add coverage workflow --- .github/workflows/ci.yml | 52 +++++++++++++++++++++++++++++++++-- .gitignore | 2 ++ pyproject.toml | 2 ++ src/test_typing_extensions.py | 7 +++++ 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eff7b4c9..b1a0e219 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,13 +64,28 @@ jobs: python-version: ${{ matrix.python-version }} allow-prereleases: true + - name: Install coverage + run: | + # Be wary that this does not install typing_extensions in the future + pip install coverage + - name: Test typing_extensions run: | # Be wary of running `pip install` here, since it becomes easy for us to # accidentally pick up typing_extensions as installed by a dependency cd src python --version # just to make sure we're running the right one - python -m unittest test_typing_extensions.py + export COVERAGE_FILE=.coverage_${{ matrix.python-version }} + # Run with coverage omit files that are executed in tempfiles + coverage run --omit ann_module*,inspect* -m unittest test_typing_extensions.py + + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: .coverage_${{ matrix.python-version }} + path: ./src/.coverage* + include-hidden-files: true + compression-level: 0 # no compression - name: Test CPython typing test suite # Test suite fails on PyPy even without typing_extensions @@ -80,7 +95,7 @@ jobs: # Run the typing test suite from CPython with typing_extensions installed, # because we monkeypatch typing under some circumstances. python -c 'import typing_extensions; import test.__main__' test_typing -v - + linting: name: Lint @@ -130,3 +145,36 @@ jobs: title: `Daily tests failed on ${new Date().toDateString()}`, body: "Runs listed here: https://github.com/python/typing_extensions/actions/workflows/ci.yml", }) + + report-coverage: + name: Report coverage + + runs-on: ubuntu-latest + + needs: [tests] + + if: ${{ always() }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3" + - name: Download coverage artifacts + uses: actions/download-artifact@v4 + with: + pattern: .coverage_* + path: . + # merge only when files are named differently + merge-multiple: true + - name: Install dependencies + run: pip install coverage + - name: Combine coverage results + run: | + # List the files to see what we have + echo "Combining coverage files:" + coverage combine --data-file=.coverage .coverage* + # add -i to ignore parsed code of temp files. + coverage report -i + coverage xml -i diff --git a/.gitignore b/.gitignore index ee36fe77..56dacc6f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ venv*/ *.swp *.pyc *.egg-info/ + +.coverage* diff --git a/pyproject.toml b/pyproject.toml index 38475b93..e329a5d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -114,3 +114,5 @@ ignore = [ [tool.ruff.lint.isort] extra-standard-library = ["tomllib"] known-first-party = ["typing_extensions", "_typed_dict_test_helper"] + + diff --git a/src/test_typing_extensions.py b/src/test_typing_extensions.py index 3ef29474..f7558978 100644 --- a/src/test_typing_extensions.py +++ b/src/test_typing_extensions.py @@ -6886,6 +6886,13 @@ def test_typing_extensions_compiles_with_opt(self): except subprocess.CalledProcessError: self.fail('Module does not compile with optimize=2 (-OO flag).') + def test_typing_extensions_is_not_installed(self): + #import importlib + #with self.assertRaises(ModuleNotFoundError): + # importlib.import_module("typing_extensions") + # Importlib tests fail on GitHub CI + # weak alternative to check that no version in site-packages is used + self.assertIn("src/typing_extensions.py", typing_extensions.__file__) class CoolEmployee(NamedTuple): name: str From 56faf0fbb1dca19fbcb803d356859be27314bdac Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 13:26:28 +0200 Subject: [PATCH 02/13] Add coverage summary --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1a0e219..bb1edbef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -178,3 +178,24 @@ jobs: # add -i to ignore parsed code of temp files. coverage report -i coverage xml -i + + - name: Code Coverage Report + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + # Alternatively use one file per python version + filename: coverage.xml + badge: true + fail_below_min: false + format: markdown + hide_branch_rate: false + hide_complexity: true + indicators: true + output: both + thresholds: '80 90' + + - name: Add Coverage PR Comment + uses: marocchino/sticky-pull-request-comment@v2 + if: github.event_name == 'pull_request' + with: + recreate: true + path: code-coverage-results.md From 045b6f79045331893d206250e7d6076bfac78397 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 13:36:41 +0200 Subject: [PATCH 03/13] add PR write permission --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb1edbef..0780ba2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ on: permissions: contents: read + pull-requests: write env: FORCE_COLOR: 1 From 21b240cd1d85bc8998fb459e13b8d7502388fce2 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 13:46:31 +0200 Subject: [PATCH 04/13] report line misses in logs --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0780ba2e..9dd1e7da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,7 +177,7 @@ jobs: echo "Combining coverage files:" coverage combine --data-file=.coverage .coverage* # add -i to ignore parsed code of temp files. - coverage report -i + coverage report -i -m coverage xml -i - name: Code Coverage Report From 3b6319d1d998a1509e70d5c5dd1e8919a3ade726 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 13:58:43 +0200 Subject: [PATCH 05/13] Remove install check again --- pyproject.toml | 2 -- src/test_typing_extensions.py | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e329a5d2..38475b93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -114,5 +114,3 @@ ignore = [ [tool.ruff.lint.isort] extra-standard-library = ["tomllib"] known-first-party = ["typing_extensions", "_typed_dict_test_helper"] - - diff --git a/src/test_typing_extensions.py b/src/test_typing_extensions.py index f7558978..b94cd54a 100644 --- a/src/test_typing_extensions.py +++ b/src/test_typing_extensions.py @@ -6886,13 +6886,7 @@ def test_typing_extensions_compiles_with_opt(self): except subprocess.CalledProcessError: self.fail('Module does not compile with optimize=2 (-OO flag).') - def test_typing_extensions_is_not_installed(self): - #import importlib - #with self.assertRaises(ModuleNotFoundError): - # importlib.import_module("typing_extensions") - # Importlib tests fail on GitHub CI - # weak alternative to check that no version in site-packages is used - self.assertIn("src/typing_extensions.py", typing_extensions.__file__) + class CoolEmployee(NamedTuple): name: str From 43842065e861186381dfa6265ede96e1ef402b4c Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 14:20:56 +0200 Subject: [PATCH 06/13] coverage not on mypy --- .github/workflows/ci.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60b37a01..957cb229 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,6 @@ on: permissions: contents: read - pull-requests: write env: FORCE_COLOR: 1 @@ -66,11 +65,13 @@ jobs: allow-prereleases: true - name: Install coverage + if: ${{ !startsWith(matrix.python-version, 'pypy') }} run: | # Be wary that this does not install typing_extensions in the future pip install coverage - - - name: Test typing_extensions + + - name: Test typing_extensions with coverage + if: ${{ !startsWith(matrix.python-version, 'pypy') }} run: | # Be wary of running `pip install` here, since it becomes easy for us to # accidentally pick up typing_extensions as installed by a dependency @@ -79,8 +80,18 @@ jobs: export COVERAGE_FILE=.coverage_${{ matrix.python-version }} # Run with coverage omit files that are executed in tempfiles coverage run --omit ann_module*,inspect* -m unittest test_typing_extensions.py + + - name: Test typing_extensions no coverage on pypy + if: ${{ startsWith(matrix.python-version, 'pypy') }} + run: | + # Be wary of running `pip install` here, since it becomes easy for us to + # accidentally pick up typing_extensions as installed by a dependency + cd src + python --version # just to make sure we're running the right one + python -m unittest test_typing_extensions.py - name: Archive code coverage results + if: ${{ !startsWith(matrix.python-version, 'pypy') }} uses: actions/upload-artifact@v4 with: name: .coverage_${{ matrix.python-version }} @@ -132,6 +143,10 @@ jobs: runs-on: ubuntu-latest needs: [tests] + permissions: + contents: read + pull-requests: write + if: ${{ always() }} @@ -172,7 +187,7 @@ jobs: indicators: true output: both thresholds: '80 90' - + - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@v2 if: github.event_name == 'pull_request' From b852953f4fad8d5b6fa56218befd488ffd0d6e82 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 15:31:20 +0200 Subject: [PATCH 07/13] Feedback; include temp files in .coverage --- .github/workflows/ci.yml | 10 ++++------ src/test_typing_extensions.py | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 957cb229..fe5bc87a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,10 +77,8 @@ jobs: # accidentally pick up typing_extensions as installed by a dependency cd src python --version # just to make sure we're running the right one - export COVERAGE_FILE=.coverage_${{ matrix.python-version }} - # Run with coverage omit files that are executed in tempfiles - coverage run --omit ann_module*,inspect* -m unittest test_typing_extensions.py - + # Run tests under coverage + python -m coverage run -m unittest test_typing_extensions.py - name: Test typing_extensions no coverage on pypy if: ${{ startsWith(matrix.python-version, 'pypy') }} run: | @@ -147,7 +145,6 @@ jobs: contents: read pull-requests: write - if: ${{ always() }} steps: @@ -170,7 +167,8 @@ jobs: # List the files to see what we have echo "Combining coverage files:" coverage combine --data-file=.coverage .coverage* - # add -i to ignore parsed code of temp files. + # add -i to ignore code in ephemeral python files created in temporary + # directories during tests; this will result in warnings in the report coverage report -i -m coverage xml -i diff --git a/src/test_typing_extensions.py b/src/test_typing_extensions.py index b94cd54a..3ef29474 100644 --- a/src/test_typing_extensions.py +++ b/src/test_typing_extensions.py @@ -6887,7 +6887,6 @@ def test_typing_extensions_compiles_with_opt(self): self.fail('Module does not compile with optimize=2 (-OO flag).') - class CoolEmployee(NamedTuple): name: str cool: int From 9f1b3e100fa828695c6e43898dbe963e006d7fb3 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 15:46:52 +0200 Subject: [PATCH 08/13] check files present --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe5bc87a..cea2cc1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,7 +166,8 @@ jobs: run: | # List the files to see what we have echo "Combining coverage files:" - coverage combine --data-file=.coverage .coverage* + ls -aR .coverage* + coverage combine .coverage* # add -i to ignore code in ephemeral python files created in temporary # directories during tests; this will result in warnings in the report coverage report -i -m From 4bd0aa18c9bae02e35d10c885636e0225980590c Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 15:59:28 +0200 Subject: [PATCH 09/13] Add omit to final output --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cea2cc1d..1e20d3b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -165,13 +165,14 @@ jobs: - name: Combine coverage results run: | # List the files to see what we have - echo "Combining coverage files:" + echo "Combining coverage files..." ls -aR .coverage* coverage combine .coverage* # add -i to ignore code in ephemeral python files created in temporary # directories during tests; this will result in warnings in the report - coverage report -i -m - coverage xml -i + echo "Creating coverage report..." + coverage report -i -m --omit inspect*,ann* + coverage xml -i --omit inspect*,ann* - name: Code Coverage Report uses: irongut/CodeCoverageSummary@v1.3.0 From 7a7d6b372be62571d431586fc71ea84183edec18 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 16:14:16 +0200 Subject: [PATCH 10/13] Read env --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e20d3b3..ad6afa68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,7 @@ jobs: cd src python --version # just to make sure we're running the right one # Run tests under coverage + export COVERAGE_FILE=.coverage_${{ matrix.python-version }} python -m coverage run -m unittest test_typing_extensions.py - name: Test typing_extensions no coverage on pypy if: ${{ startsWith(matrix.python-version, 'pypy') }} From ba46124c8891e113fc25ea18addd1382bd1b1ee1 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 16:45:19 +0200 Subject: [PATCH 11/13] Use pyproject.toml for coverage --- .github/workflows/ci.yml | 5 ++--- .gitignore | 1 + pyproject.toml | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad6afa68..51d9c886 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -172,13 +172,12 @@ jobs: # add -i to ignore code in ephemeral python files created in temporary # directories during tests; this will result in warnings in the report echo "Creating coverage report..." - coverage report -i -m --omit inspect*,ann* - coverage xml -i --omit inspect*,ann* + coverage report + coverage xml - name: Code Coverage Report uses: irongut/CodeCoverageSummary@v1.3.0 with: - # Alternatively use one file per python version filename: coverage.xml badge: true fail_below_min: false diff --git a/.gitignore b/.gitignore index 56dacc6f..bcbd4ce9 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ venv*/ *.egg-info/ .coverage* +coverage.xml diff --git a/pyproject.toml b/pyproject.toml index 38475b93..8c0f02d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -114,3 +114,9 @@ ignore = [ [tool.ruff.lint.isort] extra-standard-library = ["tomllib"] known-first-party = ["typing_extensions", "_typed_dict_test_helper"] + +[tool.coverage.report] +show_missing = true +# Omit files that are created in temporary directories during tests. +omit = ["inspect*", "ann*"] +ignore_errors = true From b9613f74b94b75532931c576211eed2116246771 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 16:53:00 +0200 Subject: [PATCH 12/13] clean comment --- .github/workflows/ci.yml | 2 -- pyproject.toml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51d9c886..32d23e16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,8 +169,6 @@ jobs: echo "Combining coverage files..." ls -aR .coverage* coverage combine .coverage* - # add -i to ignore code in ephemeral python files created in temporary - # directories during tests; this will result in warnings in the report echo "Creating coverage report..." coverage report coverage xml diff --git a/pyproject.toml b/pyproject.toml index 8c0f02d3..0f4f4e9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,5 +118,6 @@ known-first-party = ["typing_extensions", "_typed_dict_test_helper"] [tool.coverage.report] show_missing = true # Omit files that are created in temporary directories during tests. +# If not explicitly omitted they will result in warnings in the report. omit = ["inspect*", "ann*"] ignore_errors = true From 034ec43330304ee6a5e46034957f078235fd1257 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Mon, 7 Jul 2025 18:07:01 +0200 Subject: [PATCH 13/13] Zizmor feedback: Pin actions --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf3bdd68..88b16c71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,6 +152,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Set up Python uses: actions/setup-python@v5 with: @@ -176,7 +178,7 @@ jobs: coverage xml - name: Code Coverage Report - uses: irongut/CodeCoverageSummary@v1.3.0 + uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 with: filename: coverage.xml badge: true @@ -189,7 +191,7 @@ jobs: thresholds: '80 90' - name: Add Coverage PR Comment - uses: marocchino/sticky-pull-request-comment@v2 + uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.3 if: github.event_name == 'pull_request' with: recreate: true pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy