Skip to content

Commit 9831c28

Browse files
committed
made to_write an explicit attribute of CaptureFile
1 parent b5e06ca commit 9831c28

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

CaptureFile/CaptureFile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CaptureFile:
7171
"""For in-process double checking to prevent multiple to-write opens."""
7272

7373
file_name: str
74-
to_write: InitVar[bool] = False
74+
to_write: bool = False
7575
initial_metadata: InitVar[Optional[bytes]] = None
7676
force_new_empty_file: InitVar[bool] = False
7777
encoding: Optional[str] = "utf_8"
@@ -96,7 +96,6 @@ class CaptureFile:
9696

9797
def __post_init__(
9898
self,
99-
to_write: bool,
10099
initial_metadata: Optional[bytes],
101100
force_new_empty_file: bool,
102101
):
@@ -105,9 +104,9 @@ def __post_init__(
105104

106105
self._file_name = Path(self.file_name)
107106

108-
if force_new_empty_file or (to_write and not self._file_name.is_file()):
107+
if force_new_empty_file or (self.to_write and not self._file_name.is_file()):
109108
self._new_file(initial_metadata)
110-
self.open(to_write)
109+
self.open(self.to_write)
111110

112111
def __str__(self):
113112
if self._file:

0 commit comments

Comments
 (0)