diff --git a/nonebot/drivers/none.py b/nonebot/drivers/none.py index d973399a..5fb357f3 100644 --- a/nonebot/drivers/none.py +++ b/nonebot/drivers/none.py @@ -27,7 +27,7 @@ HANDLED_SIGNALS = ( signal.SIGINT, # Unix signal 2. Sent by Ctrl+C. signal.SIGTERM, # Unix signal 15. Sent by `kill `. ) -if WINDOWS: +if WINDOWS: # pragma: py-win32 HANDLED_SIGNALS += (signal.SIGBREAK,) # Windows signal 21. Sent by Ctrl+Break. diff --git a/nonebot/plugin/load.py b/nonebot/plugin/load.py index 51050029..2693e8f9 100644 --- a/nonebot/plugin/load.py +++ b/nonebot/plugin/load.py @@ -15,9 +15,9 @@ from .plugin import Plugin from .manager import PluginManager from . import _managers, get_plugin, _module_name_to_plugin_name -try: +try: # pragma: py-gte-311 import tomllib # pyright: reportMissingImports=false -except ModuleNotFoundError: +except ModuleNotFoundError: # pragma: py-lt-311 import tomli as tomllib diff --git a/nonebot/rule.py b/nonebot/rule.py index 4cd1b7bc..d241f605 100644 --- a/nonebot/rule.py +++ b/nonebot/rule.py @@ -541,7 +541,7 @@ class ShellCommandRule: try: args = self.parser.parse_args(state[SHELL_ARGV]) 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)) except ParserExit as e: state[SHELL_ARGS] = e diff --git a/poetry.lock b/poetry.lock index ec8c4142..6783191c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -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]] name = "aiodns" @@ -709,6 +709,23 @@ tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.1 [package.extras] 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]] name = "distlib" version = "0.3.6" @@ -1083,7 +1100,7 @@ name = "importlib-metadata" version = "6.0.0" description = "Read metadata from Python packages" category = "main" -optional = true +optional = false python-versions = ">=3.7" files = [ {file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"}, @@ -2448,7 +2465,7 @@ name = "zipp" version = "3.15.0" description = "Backport of pathlib-compatible object wrapper for zip files" category = "main" -optional = true +optional = false python-versions = ">=3.7" files = [ {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, @@ -2470,4 +2487,4 @@ websockets = ["websockets"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "521db6409b1c3f5432b3f3eb5cdf85f7c3b199c0aac668f8a129b3b90f21d5ed" +content-hash = "6b7553642e99d6353153e941103a82f7ddcaff2b0453c8b3d8a85a3e2de41874" diff --git a/pyproject.toml b/pyproject.toml index 420290c4..9af00e56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ nonebug = "^0.3.0" pytest-cov = "^4.0.0" pytest-xdist = "^3.0.2" pytest-asyncio = "^0.20.0" +coverage-conditional-plugin = "^0.8.0" [tool.poetry.group.docs.dependencies] nb-autodoc = "^1.0.0a5" diff --git a/tests/.coveragerc b/tests/.coveragerc index 4b536aea..8f3134a9 100644 --- a/tests/.coveragerc +++ b/tests/.coveragerc @@ -1,3 +1,7 @@ +[run] +plugins = + coverage_conditional_plugin + [report] exclude_lines = pragma: no cover @@ -10,3 +14,12 @@ exclude_lines = \.\.\. pass 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