From f77be1770a9d93ed69d6b5a26dcbe5dbfe14e380 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 12 Feb 2023 09:27:25 -0500 Subject: fix: Path objects are ok for data_file and config_file. #1552 --- coverage/types.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'coverage/types.py') diff --git a/coverage/types.py b/coverage/types.py index b8135d05..e01f451e 100644 --- a/coverage/types.py +++ b/coverage/types.py @@ -7,9 +7,12 @@ Types for use throughout coverage.py. from __future__ import annotations +import os +import pathlib + from types import FrameType, ModuleType from typing import ( - Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, Tuple, Union, + Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, Tuple, Type, Union, TYPE_CHECKING, ) @@ -23,6 +26,14 @@ else: class Protocol: # pylint: disable=missing-class-docstring pass +## File paths + +# For arguments that are file paths: +FilePath = Union[str, os.PathLike] +# For testing FilePath arguments +FilePathClasses = [str, pathlib.Path] +FilePathType = Union[Type[str], Type[pathlib.Path]] + ## Python tracing class TTraceFn(Protocol): -- cgit v1.2.1