add coverage condition annotation (#1858)

This commit is contained in:
Ju4tCode 2023-03-29 11:57:33 +08:00 committed by GitHub
parent ae08568daf
commit 1213e89bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 8 deletions

View File

@ -27,7 +27,7 @@ HANDLED_SIGNALS = (
signal.SIGINT, # Unix signal 2. Sent by Ctrl+C. signal.SIGINT, # Unix signal 2. Sent by Ctrl+C.
signal.SIGTERM, # Unix signal 15. Sent by `kill <pid>`. signal.SIGTERM, # Unix signal 15. Sent by `kill <pid>`.
) )
if WINDOWS: if WINDOWS: # pragma: py-win32
HANDLED_SIGNALS += (signal.SIGBREAK,) # Windows signal 21. Sent by Ctrl+Break. HANDLED_SIGNALS += (signal.SIGBREAK,) # Windows signal 21. Sent by Ctrl+Break.

View File

@ -15,9 +15,9 @@ from .plugin import Plugin
from .manager import PluginManager from .manager import PluginManager
from . import _managers, get_plugin, _module_name_to_plugin_name from . import _managers, get_plugin, _module_name_to_plugin_name
try: try: # pragma: py-gte-311
import tomllib # pyright: reportMissingImports=false import tomllib # pyright: reportMissingImports=false
except ModuleNotFoundError: except ModuleNotFoundError: # pragma: py-lt-311
import tomli as tomllib import tomli as tomllib

View File

@ -541,7 +541,7 @@ class ShellCommandRule:
try: try:
args = self.parser.parse_args(state[SHELL_ARGV]) args = self.parser.parse_args(state[SHELL_ARGV])
state[SHELL_ARGS] = args state[SHELL_ARGS] = args
except ArgumentError as e: except ArgumentError as e: # pragma: py-gte-39
state[SHELL_ARGS] = ParserExit(status=2, message=str(e)) state[SHELL_ARGS] = ParserExit(status=2, message=str(e))
except ParserExit as e: except ParserExit as e:
state[SHELL_ARGS] = e state[SHELL_ARGS] = e

25
poetry.lock generated
View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. # This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand.
[[package]] [[package]]
name = "aiodns" name = "aiodns"
@ -709,6 +709,23 @@ tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.1
[package.extras] [package.extras]
toml = ["tomli"] toml = ["tomli"]
[[package]]
name = "coverage-conditional-plugin"
version = "0.8.0"
description = "Conditional coverage based on any rules you define!"
category = "dev"
optional = false
python-versions = ">=3.7,<4.0"
files = [
{file = "coverage-conditional-plugin-0.8.0.tar.gz", hash = "sha256:e6564944a32ccc962f8c0000ac618efa5f5ff232cb9bcc677ce98546dfa61e6d"},
{file = "coverage_conditional_plugin-0.8.0-py3-none-any.whl", hash = "sha256:421079fbf9676c48397dd14254746e5e2656280b87ef83835701dd233053b9cd"},
]
[package.dependencies]
coverage = ">=5,<8"
importlib_metadata = {version = "*", markers = "python_version < \"3.10\""}
packaging = ">=20.4"
[[package]] [[package]]
name = "distlib" name = "distlib"
version = "0.3.6" version = "0.3.6"
@ -1083,7 +1100,7 @@ name = "importlib-metadata"
version = "6.0.0" version = "6.0.0"
description = "Read metadata from Python packages" description = "Read metadata from Python packages"
category = "main" category = "main"
optional = true optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
{file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"}, {file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"},
@ -2448,7 +2465,7 @@ name = "zipp"
version = "3.15.0" version = "3.15.0"
description = "Backport of pathlib-compatible object wrapper for zip files" description = "Backport of pathlib-compatible object wrapper for zip files"
category = "main" category = "main"
optional = true optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
{file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"},
@ -2470,4 +2487,4 @@ websockets = ["websockets"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "521db6409b1c3f5432b3f3eb5cdf85f7c3b199c0aac668f8a129b3b90f21d5ed" content-hash = "6b7553642e99d6353153e941103a82f7ddcaff2b0453c8b3d8a85a3e2de41874"

View File

@ -49,6 +49,7 @@ nonebug = "^0.3.0"
pytest-cov = "^4.0.0" pytest-cov = "^4.0.0"
pytest-xdist = "^3.0.2" pytest-xdist = "^3.0.2"
pytest-asyncio = "^0.20.0" pytest-asyncio = "^0.20.0"
coverage-conditional-plugin = "^0.8.0"
[tool.poetry.group.docs.dependencies] [tool.poetry.group.docs.dependencies]
nb-autodoc = "^1.0.0a5" nb-autodoc = "^1.0.0a5"

View File

@ -1,3 +1,7 @@
[run]
plugins =
coverage_conditional_plugin
[report] [report]
exclude_lines = exclude_lines =
pragma: no cover pragma: no cover
@ -10,3 +14,12 @@ exclude_lines =
\.\.\. \.\.\.
pass pass
if __name__ == .__main__.: if __name__ == .__main__.:
[coverage_conditional_plugin]
rules =
"sys_platform == 'win32'": py-win32
"sys_platform == 'linux'": py-linux
"sys_platform == 'darwin'": py-darwin
"sys_version_info >= (3, 9)": py-gte-39
"sys_version_info >= (3, 11)": py-gte-311
"sys_version_info < (3, 11)": py-lt-311