Apply auto-fixes for RUF rule

This commit is contained in:
Hugo Osvaldo Barrera 2025-08-29 10:11:41 +02:00
parent 9677cf9812
commit b5d3b7e578
15 changed files with 28 additions and 28 deletions

View file

@ -52,7 +52,7 @@ def test_xml_specialchars(char):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"href", "href",
[ [
"/dav/calendars/user/testuser/123/UID%253A20210609T084907Z-@synaps-web-54fddfdf7-7kcfm%250A.ics", # noqa: E501 "/dav/calendars/user/testuser/123/UID%253A20210609T084907Z-@synaps-web-54fddfdf7-7kcfm%250A.ics",
], ],
) )
def test_normalize_href(href): def test_normalize_href(href):

View file

@ -13,7 +13,7 @@ try:
"url": "https://brutus.lostpackets.de/davical-test/caldav.php/", "url": "https://brutus.lostpackets.de/davical-test/caldav.php/",
} }
except KeyError as e: except KeyError as e:
pytestmark = pytest.mark.skip(f"Missing envkey: {str(e)}") pytestmark = pytest.mark.skip(f"Missing envkey: {e!s}")
@pytest.mark.flaky(reruns=5) @pytest.mark.flaky(reruns=5)

View file

@ -10,7 +10,7 @@ class ServerMixin:
def get_storage_args(self, item_type, slow_create_collection): def get_storage_args(self, item_type, slow_create_collection):
if item_type != "VEVENT": if item_type != "VEVENT":
# iCloud collections can either be calendars or task lists. # iCloud collections can either be calendars or task lists.
# See https://github.com/pimutils/vdirsyncer/pull/593#issuecomment-285941615 # noqa # See https://github.com/pimutils/vdirsyncer/pull/593#issuecomment-285941615
pytest.skip("iCloud doesn't support anything else than VEVENT") pytest.skip("iCloud doesn't support anything else than VEVENT")
async def inner(collection="test"): async def inner(collection="test"):

View file

@ -161,12 +161,12 @@ def test_null_collection_with_named_collection(tmpdir, runner):
[storage foo] [storage foo]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/foo/" path = "{tmpdir!s}/foo/"
fileext = ".txt" fileext = ".txt"
[storage bar] [storage bar]
type = "singlefile" type = "singlefile"
path = "{str(tmpdir)}/bar.txt" path = "{tmpdir!s}/bar.txt"
""" """
) )
) )

View file

@ -14,12 +14,12 @@ def test_get_password_from_command(tmpdir, runner):
[storage foo] [storage foo]
type.fetch = ["shell", "echo filesystem"] type.fetch = ["shell", "echo filesystem"]
path = "{str(tmpdir)}/foo/" path = "{tmpdir!s}/foo/"
fileext.fetch = ["command", "echo", ".txt"] fileext.fetch = ["command", "echo", ".txt"]
[storage bar] [storage bar]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/bar/" path = "{tmpdir!s}/bar/"
fileext.fetch = ["prompt", "Fileext for bar"] fileext.fetch = ["prompt", "Fileext for bar"]
""" """
) )

View file

@ -288,12 +288,12 @@ def test_create_collections(collections, tmpdir, runner):
[storage foo] [storage foo]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/foo/" path = "{tmpdir!s}/foo/"
fileext = ".txt" fileext = ".txt"
[storage bar] [storage bar]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/bar/" path = "{tmpdir!s}/bar/"
fileext = ".txt" fileext = ".txt"
""" """
) )
@ -321,12 +321,12 @@ def test_ident_conflict(tmpdir, runner):
[storage foo] [storage foo]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/foo/" path = "{tmpdir!s}/foo/"
fileext = ".txt" fileext = ".txt"
[storage bar] [storage bar]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/bar/" path = "{tmpdir!s}/bar/"
fileext = ".txt" fileext = ".txt"
""" """
) )
@ -375,7 +375,7 @@ def test_unknown_storage(tmpdir, runner, existing, missing):
[storage {existing}] [storage {existing}]
type = "filesystem" type = "filesystem"
path = "{str(tmpdir)}/{existing}/" path = "{tmpdir!s}/{existing}/"
fileext = ".txt" fileext = ".txt"
""" """
) )
@ -418,12 +418,12 @@ def test_conflict_resolution(tmpdir, runner, resolution, expect_foo, expect_bar)
[storage foo] [storage foo]
type = "filesystem" type = "filesystem"
fileext = ".txt" fileext = ".txt"
path = "{str(tmpdir)}/foo" path = "{tmpdir!s}/foo"
[storage bar] [storage bar]
type = "filesystem" type = "filesystem"
fileext = ".txt" fileext = ".txt"
path = "{str(tmpdir)}/bar" path = "{tmpdir!s}/bar"
""" """
) )
) )
@ -518,7 +518,7 @@ def test_fetch_only_necessary_params(tmpdir, runner):
dedent( dedent(
f""" f"""
set -e set -e
touch "{str(fetched_file)}" touch "{fetched_file!s}"
echo ".txt" echo ".txt"
""" """
) )

View file

@ -382,4 +382,4 @@ def test_component_contains():
assert "BAZ" not in item assert "BAZ" not in item
with pytest.raises(ValueError): with pytest.raises(ValueError):
42 in item # noqa: B015 42 in item

View file

@ -9,7 +9,7 @@ BUGTRACKER_HOME = PROJECT_HOME + "/issues"
DOCS_HOME = "https://vdirsyncer.pimutils.org/en/stable" DOCS_HOME = "https://vdirsyncer.pimutils.org/en/stable"
try: try:
from .version import version as __version__ # noqa from .version import version as __version__
except ImportError: # pragma: no cover except ImportError: # pragma: no cover
raise ImportError( raise ImportError(
"Failed to find (autogenerated) version.py. " "Failed to find (autogenerated) version.py. "
@ -21,7 +21,7 @@ except ImportError: # pragma: no cover
def _check_python_version(): def _check_python_version():
import sys import sys
if sys.version_info < (3, 8, 0): # noqa: UP036 if sys.version_info < (3, 8, 0):
print("vdirsyncer requires at least Python 3.8.") print("vdirsyncer requires at least Python 3.8.")
sys.exit(1) sys.exit(1)

View file

@ -93,7 +93,7 @@ def _validate_collections_param(collections):
raise ValueError("Duplicate value.") raise ValueError("Duplicate value.")
collection_names.add(collection_name) collection_names.add(collection_name)
except ValueError as e: except ValueError as e:
raise ValueError(f"`collections` parameter, position {i}: {str(e)}") raise ValueError(f"`collections` parameter, position {i}: {e!s}")
class _ConfigReader: class _ConfigReader:
@ -142,7 +142,7 @@ class _ConfigReader:
dict(_parse_options(self._parser.items(section), section=section)), dict(_parse_options(self._parser.items(section), section=section)),
) )
except ValueError as e: except ValueError as e:
raise exceptions.UserError(f'Section "{section}": {str(e)}') raise exceptions.UserError(f'Section "{section}": {e!s}')
_validate_general_section(self._general) _validate_general_section(self._general)
if getattr(self._file, "name", None): if getattr(self._file, "name", None):

View file

@ -88,7 +88,7 @@ def _strategy_command(*command: str, shell: bool = False):
return stdout.strip("\n") return stdout.strip("\n")
except OSError as e: except OSError as e:
cmd = " ".join(expanded_command) cmd = " ".join(expanded_command)
raise exceptions.UserError(f"Failed to execute command: {cmd}\n{str(e)}") raise exceptions.UserError(f"Failed to execute command: {cmd}\n{e!s}")
def _strategy_shell(*command: str): def _strategy_shell(*command: str):

View file

@ -57,7 +57,7 @@ async def metasync(storage_a, storage_b, status, keys, conflict_resolution=None)
logger.debug(f"B: {b}") logger.debug(f"B: {b}")
logger.debug(f"S: {s}") logger.debug(f"S: {s}")
if a != s and b != s or storage_a.read_only or storage_b.read_only: if (a != s and b != s) or storage_a.read_only or storage_b.read_only:
await _resolve_conflict() await _resolve_conflict()
elif a != s and b == s: elif a != s and b == s:
await _a_to_b() await _a_to_b()

View file

@ -177,7 +177,7 @@ class FilesystemStorage(Storage):
try: try:
subprocess.call([self.post_hook, fpath]) subprocess.call([self.post_hook, fpath])
except OSError as e: except OSError as e:
logger.warning(f"Error executing external hook: {str(e)}") logger.warning(f"Error executing external hook: {e!s}")
def _run_pre_deletion_hook(self, fpath): def _run_pre_deletion_hook(self, fpath):
logger.info( logger.info(
@ -186,7 +186,7 @@ class FilesystemStorage(Storage):
try: try:
subprocess.call([self.pre_deletion_hook, fpath]) subprocess.call([self.pre_deletion_hook, fpath])
except OSError as e: except OSError as e:
logger.warning(f"Error executing external hook: {str(e)}") logger.warning(f"Error executing external hook: {e!s}")
async def get_meta(self, key): async def get_meta(self, key):
fpath = os.path.join(self.path, key) fpath = os.path.join(self.path, key)

View file

@ -83,7 +83,7 @@ class HttpStorage(Storage):
) )
return result.stdout return result.stdout
except OSError as e: except OSError as e:
logger.warning(f"Error executing external command: {str(e)}") logger.warning(f"Error executing external command: {e!s}")
return raw_item return raw_item
async def list(self): async def list(self):

View file

@ -136,9 +136,9 @@ async def sync(
raise BothReadOnly raise BothReadOnly
if conflict_resolution == "a wins": if conflict_resolution == "a wins":
conflict_resolution = lambda a, b: a # noqa: E731 conflict_resolution = lambda a, b: a
elif conflict_resolution == "b wins": elif conflict_resolution == "b wins":
conflict_resolution = lambda a, b: b # noqa: E731 conflict_resolution = lambda a, b: b
status_nonempty = bool(next(status.iter_old(), None)) status_nonempty = bool(next(status.iter_old(), None))

View file

@ -77,7 +77,7 @@ def get_storage_init_specs(cls, stop_at=object):
spec = getfullargspec(cls.__init__) spec = getfullargspec(cls.__init__)
traverse_superclass = getattr(cls.__init__, "_traverse_superclass", True) traverse_superclass = getattr(cls.__init__, "_traverse_superclass", True)
if traverse_superclass: if traverse_superclass:
if traverse_superclass is True: # noqa if traverse_superclass is True:
supercls = next( supercls = next(
getattr(x.__init__, "__objclass__", x) for x in cls.__mro__[1:] getattr(x.__init__, "__objclass__", x) for x in cls.__mro__[1:]
) )