summaryrefslogtreecommitdiff
path: root/coverage/disposition.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-12-30 07:05:42 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-12-30 09:57:46 -0500
commit27990185352f035bafbb0cc7c8ac4159e87fe070 (patch)
treee3f0a1a19f893347c7909294db770e6aa8e514d6 /coverage/disposition.py
parentc802be289c40f896e910a4f34f1ce27aedc44a0b (diff)
downloadpython-coveragepy-git-27990185352f035bafbb0cc7c8ac4159e87fe070.tar.gz
mypy: inorout.py, disposition.py, and part of control.py
Diffstat (limited to 'coverage/disposition.py')
-rw-r--r--coverage/disposition.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/coverage/disposition.py b/coverage/disposition.py
index 34819f42..5237c364 100644
--- a/coverage/disposition.py
+++ b/coverage/disposition.py
@@ -3,11 +3,26 @@
"""Simple value objects for tracking what to do with files."""
+from __future__ import annotations
+
+from typing import Optional, Type, TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from coverage.plugin import FileTracer
+
class FileDisposition:
"""A simple value type for recording what to do with a file."""
- def __repr__(self):
+ original_filename: str
+ canonical_filename: str
+ source_filename: Optional[str]
+ trace: bool
+ reason: str
+ file_tracer: Optional[FileTracer]
+ has_dynamic_filename: bool
+
+ def __repr__(self) -> str:
return f"<FileDisposition {self.canonical_filename!r}: trace={self.trace}>"
@@ -15,7 +30,7 @@ class FileDisposition:
# be implemented in either C or Python. Acting on them is done with these
# functions.
-def disposition_init(cls, original_filename):
+def disposition_init(cls: Type[FileDisposition], original_filename: str) -> FileDisposition:
"""Construct and initialize a new FileDisposition object."""
disp = cls()
disp.original_filename = original_filename
@@ -28,7 +43,7 @@ def disposition_init(cls, original_filename):
return disp
-def disposition_debug_msg(disp):
+def disposition_debug_msg(disp: FileDisposition) -> str:
"""Make a nice debug message of what the FileDisposition is doing."""
if disp.trace:
msg = f"Tracing {disp.original_filename!r}"