Skip to content

Commit 4e39b68

Browse files
authored
Improve coverage. (#481)
1 parent 7d20db2 commit 4e39b68

24 files changed

+122
-57
lines changed

.coveragerc

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/source/changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and
2828
- {pull}`479` gives skips a higher precedence as an outcome than ancestor failed.
2929
- {pull}`480` removes the check for missing root nodes from the generation of the DAG.
3030
It is delegated to the check during the execution.
31+
- {pull}`481` improves coverage.
3132

3233
## 0.4.1 - 2023-10-11
3334

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,11 @@ python_version = "3.8"
193193

194194
[tool.check-manifest]
195195
ignore = ["src/_pytask/_version.py"]
196+
197+
[tool.coverage.report]
198+
exclude_also = [
199+
"pragma: no cover",
200+
"if TYPE_CHECKING.*:",
201+
"\\.\\.\\.",
202+
"def __repr__",
203+
]

src/_pytask/_hashlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from typing import Any
88

99

10-
if sys.version_info >= (3, 11):
10+
if sys.version_info >= (3, 11): # pragma: no cover
1111
from hashlib import file_digest
12-
else:
12+
else: # pragma: no cover
1313
# This tuple and __get_builtin_constructor() must be modified if a new
1414
# always available algorithm is added.
1515
__always_supported = (

src/_pytask/_inspect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
__all__ = ["get_annotations"]
1212

1313

14-
if sys.version_info >= (3, 10):
14+
if sys.version_info >= (3, 10): # pragma: no cover
1515
from inspect import get_annotations
16-
else:
16+
else: # pragma: no cover
1717

1818
def get_annotations( # noqa: C901, PLR0912, PLR0915
1919
obj: Callable[..., object] | type[Any] | types.ModuleType,

src/_pytask/clean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def clean(**raw_config: Any) -> NoReturn: # noqa: C901, PLR0912
106106
config = pm.hook.pytask_configure(pm=pm, raw_config=raw_config)
107107
session = Session.from_config(config)
108108

109-
except Exception: # noqa: BLE001
109+
except Exception: # noqa: BLE001 # pragma: no cover
110110
session = Session(exit_code=ExitCode.CONFIGURATION_FAILED)
111111
console.print(Traceback(sys.exc_info()))
112112

@@ -160,7 +160,7 @@ def clean(**raw_config: Any) -> NoReturn: # noqa: C901, PLR0912
160160
session.exit_code = ExitCode.COLLECTION_FAILED
161161
console.rule(style="failed")
162162

163-
except Exception: # noqa: BLE001
163+
except Exception: # noqa: BLE001 # pragma: no cover
164164
console.print(Traceback(sys.exc_info()))
165165
console.rule(style="failed")
166166
session.exit_code = ExitCode.FAILED

src/_pytask/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
}
2121

2222

23-
if parse_version(click.__version__) < parse_version("8"):
23+
if parse_version(click.__version__) < parse_version("8"): # pragma: no cover
2424
_VERSION_OPTION_KWARGS: dict[str, Any] = {}
25-
else:
25+
else: # pragma: no cover
2626
_VERSION_OPTION_KWARGS = {"package_name": "pytask"}
2727

2828

src/_pytask/collect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def pytask_collect(session: Session) -> bool:
6363

6464
try:
6565
session.hook.pytask_collect_modify_tasks(session=session, tasks=session.tasks)
66-
except Exception: # noqa: BLE001
66+
except Exception: # noqa: BLE001 # pragma: no cover
6767
report = CollectionReport.from_exception(
6868
outcome=CollectionOutcome.FAIL, exc_info=sys.exc_info()
6969
)
@@ -370,7 +370,7 @@ def _raise_error_if_casing_of_path_is_wrong(
370370
path: Path, check_casing_of_paths: bool
371371
) -> None:
372372
"""Raise an error if the path does not have the correct casing."""
373-
if (
373+
if ( # pragma: no cover
374374
not IS_FILE_SYSTEM_CASE_SENSITIVE
375375
and sys.platform == "win32"
376376
and check_casing_of_paths

src/_pytask/collect_command.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def collect(**raw_config: Any | None) -> NoReturn:
6262
config = pm.hook.pytask_configure(pm=pm, raw_config=raw_config)
6363
session = Session.from_config(config)
6464

65-
except (ConfigurationError, Exception):
65+
except (ConfigurationError, Exception): # pragma: no cover
6666
session = Session(exit_code=ExitCode.CONFIGURATION_FAILED)
6767
console.print_exception()
6868

@@ -90,13 +90,13 @@ def collect(**raw_config: Any | None) -> NoReturn:
9090
console.print()
9191
console.rule(style="neutral")
9292

93-
except CollectionError:
93+
except CollectionError: # pragma: no cover
9494
session.exit_code = ExitCode.COLLECTION_FAILED
9595

96-
except ResolvingDependenciesError:
96+
except ResolvingDependenciesError: # pragma: no cover
9797
session.exit_code = ExitCode.DAG_FAILED
9898

99-
except Exception: # noqa: BLE001
99+
except Exception: # noqa: BLE001 # pragma: no cover
100100
session.exit_code = ExitCode.FAILED
101101
console.print_exception()
102102
console.rule(style="failed")

src/_pytask/collect_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
if sys.version_info >= (3, 9):
3636
from typing import Annotated
37-
else:
37+
else: # pragma: no cover
3838
from typing_extensions import Annotated
3939

4040
if TYPE_CHECKING:
@@ -598,7 +598,7 @@ def _collect_decorator_node(
598598
collected_node = session.hook.pytask_collect_node(
599599
session=session, path=path, node_info=node_info
600600
)
601-
if collected_node is None:
601+
if collected_node is None: # pragma: no cover
602602
msg = f"{node!r} cannot be parsed as a {kind} for task {name!r} in {path!r}."
603603
raise NodeNotCollectedError(msg)
604604

@@ -628,7 +628,7 @@ def _collect_dependency(
628628
collected_node = session.hook.pytask_collect_node(
629629
session=session, path=path, node_info=node_info
630630
)
631-
if collected_node is None:
631+
if collected_node is None: # pragma: no cover
632632
msg = (
633633
f"{node!r} cannot be parsed as a dependency for task {name!r} in {path!r}."
634634
)
@@ -673,7 +673,7 @@ def _collect_product(
673673
session=session, path=path, node_info=node_info
674674
)
675675

676-
if collected_node is None:
676+
if collected_node is None: # pragma: no cover
677677
msg = (
678678
f"{node!r} can't be parsed as a product for task {task_name!r} in {path!r}."
679679
)

0 commit comments

Comments
 (0)