Skip to content

Commit

Permalink
feat(tests): Do not include type checking code in coverage report (#3327
Browse files Browse the repository at this point in the history
)

This should not count lines (or rather if blocks) that start with if TYPE_CHECKING in the code coverage report, because this code is only evaluated when checking types with mypy.
  • Loading branch information
antonpirker committed Jul 23, 2024
1 parent 357d6f5 commit 0812858
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-aws-lambda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-cloud-computing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integrations-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-data-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: supercharge/redis-github-action@1.8.0
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
uses: supercharge/redis-github-action@1.8.0
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- uses: getsentry/action-clickhouse-in-ci@v1
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
- uses: getsentry/action-clickhouse-in-ci@v1
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-miscellaneous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-web-frameworks-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integrations-web-frameworks-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
allow-prereleases: true
- name: Setup Test Env
run: |
pip install coverage tox
pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ extend-exclude = '''
| .*_pb2_grpc.py # exclude autogenerated Protocol Buffer files anywhere in the project
)
'''
[tool.coverage.report]
exclude_also = [
"if TYPE_CHECKING:",
]
3 changes: 1 addition & 2 deletions scripts/split-tox-gh-actions/templates/test_group.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@

- name: Setup Test Env
run: |
pip install coverage tox

pip install "coverage[toml]" tox
- name: Erase coverage
run: |
coverage erase
Expand Down

0 comments on commit 0812858

Please sign in to comment.