make mypy happy

This commit is contained in:
Thomas Waldmann 2025-12-06 06:10:36 +01:00
parent 2e9ebe4d95
commit c9ebeba933
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
3 changed files with 27 additions and 9 deletions

View file

@ -9,11 +9,19 @@ import tempfile
import time
from collections import defaultdict, Counter
from signal import SIGINT
from typing import TYPE_CHECKING
from .constants import ROBJ_FILE_STREAM, zeros
from .fuse_impl import llfuse, has_pyfuse3
from .platform import ENOATTR
if TYPE_CHECKING:
# For type checking, assume llfuse is available
# This allows mypy to understand llfuse.Operations
import llfuse
from .fuse_impl import has_pyfuse3
else:
from .fuse_impl import llfuse, has_pyfuse3
if has_pyfuse3:
import trio

View file

@ -3,19 +3,24 @@ Loads the library for the FUSE implementation.
"""
import os
import types
from .platform import ENOATTR # noqa
BORG_FUSE_IMPL = os.environ.get("BORG_FUSE_IMPL", "mfusepy,pyfuse3,llfuse")
hlfuse: types.ModuleType | None = None
llfuse: types.ModuleType | None = None
for FUSE_IMPL in BORG_FUSE_IMPL.split(","):
FUSE_IMPL = FUSE_IMPL.strip()
if FUSE_IMPL == "pyfuse3":
try:
import pyfuse3 as llfuse
import pyfuse3
except ImportError:
pass
else:
llfuse = pyfuse3
has_llfuse = False
has_pyfuse3 = True
has_mfusepy = False
@ -24,10 +29,11 @@ for FUSE_IMPL in BORG_FUSE_IMPL.split(","):
break
elif FUSE_IMPL == "llfuse":
try:
import llfuse
import llfuse as llfuse_module
except ImportError:
pass
else:
llfuse = llfuse_module
has_llfuse = True
has_pyfuse3 = False
has_mfusepy = False
@ -36,11 +42,11 @@ for FUSE_IMPL in BORG_FUSE_IMPL.split(","):
break
elif FUSE_IMPL == "mfusepy":
try:
import mfusepy as hlfuse
import mfusepy
except ImportError:
pass
else:
llfuse = None # noqa
hlfuse = mfusepy
has_llfuse = False
has_pyfuse3 = False
has_mfusepy = True
@ -51,8 +57,6 @@ for FUSE_IMPL in BORG_FUSE_IMPL.split(","):
else:
raise RuntimeError("Unknown FUSE implementation in BORG_FUSE_IMPL: '%s'." % BORG_FUSE_IMPL)
else:
llfuse = None # noqa
hlfuse = None # noqa
has_llfuse = False
has_pyfuse3 = False
has_mfusepy = False

View file

@ -5,10 +5,16 @@ import os
import stat
import time
from collections import Counter
from typing import TYPE_CHECKING
from .constants import ROBJ_FILE_STREAM, zeros, ROBJ_DONTCARE
from .fuse_impl import hlfuse
if TYPE_CHECKING:
# For type checking, assume mfusepy is available
# This allows mypy to understand hlfuse.Operations
import mfusepy as hlfuse
else:
from .fuse_impl import hlfuse
from .logger import create_logger
@ -28,7 +34,7 @@ from .repository import Repository
from .remote import RemoteRepository
BLOCK_SIZE = 512 # Standard filesystem block size for st_blocks and statfs
DEBUG_LOG = None # os.path.join(os.getcwd(), "fuse_debug.log")
DEBUG_LOG: str | None = None # os.path.join(os.getcwd(), "fuse_debug.log")
def debug_log(msg):