Skip to content

Commit 5216f99

Browse files
committed
Update mypy control on optional module use
1 parent 377ab8e commit 5216f99

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

CaptureFile/CaptureFile.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ def __refresh(self, /):
352352
delta = (nodes[0].serial_number - nodes[1].serial_number) & 0xFFFFFFFF
353353
if delta not in (1, 0xFFFFFFFF):
354354
raise InvalidCaptureFile(
355-
"Invalid capture file -- master nodes are valid but have non-consecutive serial numbers."
355+
"Invalid capture file -- master nodes are valid but have"
356+
" non-consecutive serial numbers."
356357
)
357358
current_master_node_index = 0 if delta == 1 else 1
358359
else:
@@ -421,14 +422,14 @@ def _acquire_master_nodes_lock_internal(self, lock: bool, /):
421422
else:
422423
# we are probably on some Unix variant
423424
# added comments below to suppress my-py errors when we are viewing code on Windows
424-
lock_type = fcntl.LOCK_EX if self.to_write else fcntl.LOCK_SH
425+
lock_type = fcntl.LOCK_EX if self.to_write else fcntl.LOCK_SH # type: ignore[attr-defined]
425426
lock_mode = lock_type if lock else fcntl.LOCK_UN # type: ignore[attr-defined]
426-
fcntl.lockf(
427+
fcntl.lockf( # type: ignore[attr-defined]
427428
self._file.fileno(),
428429
lock_mode,
429430
lock_size,
430431
self._config.page_size,
431-
) # type: ignore[attr-defined]
432+
)
432433

433434
def get_metadata(self, /) -> Optional[bytes]:
434435
"""Returns the binary metadata that was stored in the capture file on
@@ -481,7 +482,8 @@ def set_metadata(self, new_metadata: Optional[bytes], /):
481482

482483
if not self.to_write:
483484
raise CaptureFileNotOpenForWrite(
484-
f'Cannot set the metadata of "{self.file_name}" because it is not open for writting.'
485+
f'Cannot set the metadata of "{self.file_name}" because it is not open'
486+
" for writting."
485487
)
486488

487489
self._metadata = new_metadata
@@ -533,7 +535,8 @@ def record_generator(
533535

534536
if not self._file:
535537
raise CaptureFileNotOpen(
536-
f'Cannot set iterate over the records of "{self.file_name}" because it is not open.'
538+
f'Cannot set iterate over the records of "{self.file_name}" because it'
539+
" is not open."
537540
)
538541

539542
if starting_record_number < 1:
@@ -801,7 +804,8 @@ def add_record(self, record: Record, /) -> int:
801804

802805
if not self.to_write:
803806
raise CaptureFileNotOpenForWrite(
804-
f'Cannot add a record to "{self.file_name}" because it is not open for writting.'
807+
f'Cannot add a record to "{self.file_name}" because it is not open for'
808+
" writting."
805809
)
806810

807811
self._current_master_node.rightmost_path.add_child_to_rightmost_node(
@@ -950,8 +954,8 @@ def read(cls, file, /) -> "CaptureFileConfiguration":
950954

951955
if version > cls.current_version:
952956
raise InvalidCaptureFile(
953-
f"{file.name} was created in version {version} format."
954-
f" The highest version supported by this program is {cls.current_version}."
957+
f"{file.name} was created in version {version} format. The highest"
958+
f" version supported by this program is {cls.current_version}."
955959
)
956960
return cls(version, page_size, compression_block_size, fan_out)
957961

0 commit comments

Comments
 (0)