commit:     3422a8c3a4b67d87716b22dfd290165b0bc9d9ce
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Nov 25 17:32:15 2025 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Fri Nov 28 22:32:35 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=3422a8c3

chore: annotate AtomicWriteFile_mixin

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/snakeoil/fileutils.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/snakeoil/fileutils.py b/src/snakeoil/fileutils.py
index 07746d8..4fac0a3 100644
--- a/src/snakeoil/fileutils.py
+++ b/src/snakeoil/fileutils.py
@@ -2,6 +2,7 @@
 file related operations, mainly reading
 """
 
+import abc
 import mmap
 import os
 from functools import partial
@@ -51,7 +52,7 @@ def mmap_or_open_for_read(path: str):
         raise
 
 
-class AtomicWriteFile_mixin:
+class AtomicWriteFile_mixin(abc.ABC):
     """File class that stores the changes in a tempfile.
 
     Upon invocation of the close method, this class will use
@@ -68,6 +69,14 @@ class AtomicWriteFile_mixin:
     closed, the contents are discarded and a warning is issued.
     """
 
+    __slots__ = ("_is_finalized", "_computed_mode", "_original_fp", "_temp_fp")
+
+    @abc.abstractmethod
+    def _actual_init(self) -> None: ...
+
+    @abc.abstractmethod
+    def _real_close(self) -> None: ...
+
     def __init__(self, fp, binary=False, perms=None, uid=-1, gid=-1):
         """
         :param fp: filepath to write to upon close
@@ -135,6 +144,7 @@ class AtomicWriteFile_mixin:
 
 class AtomicWriteFile(AtomicWriteFile_mixin):
     __doc__ = AtomicWriteFile_mixin.__doc__
+    __slots__ = ("raw",)
 
     def _actual_init(self):
         self.raw = open(self._temp_fp, mode=self._computed_mode)

Reply via email to