mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Apply auto-fixes for RUF rule
This commit is contained in:
parent
9677cf9812
commit
b5d3b7e578
15 changed files with 28 additions and 28 deletions
|
|
@ -52,7 +52,7 @@ def test_xml_specialchars(char):
|
|||
@pytest.mark.parametrize(
|
||||
"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):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ try:
|
|||
"url": "https://brutus.lostpackets.de/davical-test/caldav.php/",
|
||||
}
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ServerMixin:
|
|||
def get_storage_args(self, item_type, slow_create_collection):
|
||||
if item_type != "VEVENT":
|
||||
# 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")
|
||||
|
||||
async def inner(collection="test"):
|
||||
|
|
|
|||
|
|
@ -161,12 +161,12 @@ def test_null_collection_with_named_collection(tmpdir, runner):
|
|||
|
||||
[storage foo]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/foo/"
|
||||
path = "{tmpdir!s}/foo/"
|
||||
fileext = ".txt"
|
||||
|
||||
[storage bar]
|
||||
type = "singlefile"
|
||||
path = "{str(tmpdir)}/bar.txt"
|
||||
path = "{tmpdir!s}/bar.txt"
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ def test_get_password_from_command(tmpdir, runner):
|
|||
|
||||
[storage foo]
|
||||
type.fetch = ["shell", "echo filesystem"]
|
||||
path = "{str(tmpdir)}/foo/"
|
||||
path = "{tmpdir!s}/foo/"
|
||||
fileext.fetch = ["command", "echo", ".txt"]
|
||||
|
||||
[storage bar]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/bar/"
|
||||
path = "{tmpdir!s}/bar/"
|
||||
fileext.fetch = ["prompt", "Fileext for bar"]
|
||||
"""
|
||||
)
|
||||
|
|
|
|||
|
|
@ -288,12 +288,12 @@ def test_create_collections(collections, tmpdir, runner):
|
|||
|
||||
[storage foo]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/foo/"
|
||||
path = "{tmpdir!s}/foo/"
|
||||
fileext = ".txt"
|
||||
|
||||
[storage bar]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/bar/"
|
||||
path = "{tmpdir!s}/bar/"
|
||||
fileext = ".txt"
|
||||
"""
|
||||
)
|
||||
|
|
@ -321,12 +321,12 @@ def test_ident_conflict(tmpdir, runner):
|
|||
|
||||
[storage foo]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/foo/"
|
||||
path = "{tmpdir!s}/foo/"
|
||||
fileext = ".txt"
|
||||
|
||||
[storage bar]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/bar/"
|
||||
path = "{tmpdir!s}/bar/"
|
||||
fileext = ".txt"
|
||||
"""
|
||||
)
|
||||
|
|
@ -375,7 +375,7 @@ def test_unknown_storage(tmpdir, runner, existing, missing):
|
|||
|
||||
[storage {existing}]
|
||||
type = "filesystem"
|
||||
path = "{str(tmpdir)}/{existing}/"
|
||||
path = "{tmpdir!s}/{existing}/"
|
||||
fileext = ".txt"
|
||||
"""
|
||||
)
|
||||
|
|
@ -418,12 +418,12 @@ def test_conflict_resolution(tmpdir, runner, resolution, expect_foo, expect_bar)
|
|||
[storage foo]
|
||||
type = "filesystem"
|
||||
fileext = ".txt"
|
||||
path = "{str(tmpdir)}/foo"
|
||||
path = "{tmpdir!s}/foo"
|
||||
|
||||
[storage bar]
|
||||
type = "filesystem"
|
||||
fileext = ".txt"
|
||||
path = "{str(tmpdir)}/bar"
|
||||
path = "{tmpdir!s}/bar"
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
|
@ -518,7 +518,7 @@ def test_fetch_only_necessary_params(tmpdir, runner):
|
|||
dedent(
|
||||
f"""
|
||||
set -e
|
||||
touch "{str(fetched_file)}"
|
||||
touch "{fetched_file!s}"
|
||||
echo ".txt"
|
||||
"""
|
||||
)
|
||||
|
|
|
|||
|
|
@ -382,4 +382,4 @@ def test_component_contains():
|
|||
assert "BAZ" not in item
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
42 in item # noqa: B015
|
||||
42 in item
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ BUGTRACKER_HOME = PROJECT_HOME + "/issues"
|
|||
DOCS_HOME = "https://vdirsyncer.pimutils.org/en/stable"
|
||||
|
||||
try:
|
||||
from .version import version as __version__ # noqa
|
||||
from .version import version as __version__
|
||||
except ImportError: # pragma: no cover
|
||||
raise ImportError(
|
||||
"Failed to find (autogenerated) version.py. "
|
||||
|
|
@ -21,7 +21,7 @@ except ImportError: # pragma: no cover
|
|||
def _check_python_version():
|
||||
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.")
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def _validate_collections_param(collections):
|
|||
raise ValueError("Duplicate value.")
|
||||
collection_names.add(collection_name)
|
||||
except ValueError as e:
|
||||
raise ValueError(f"`collections` parameter, position {i}: {str(e)}")
|
||||
raise ValueError(f"`collections` parameter, position {i}: {e!s}")
|
||||
|
||||
|
||||
class _ConfigReader:
|
||||
|
|
@ -142,7 +142,7 @@ class _ConfigReader:
|
|||
dict(_parse_options(self._parser.items(section), section=section)),
|
||||
)
|
||||
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)
|
||||
if getattr(self._file, "name", None):
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ def _strategy_command(*command: str, shell: bool = False):
|
|||
return stdout.strip("\n")
|
||||
except OSError as e:
|
||||
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):
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ async def metasync(storage_a, storage_b, status, keys, conflict_resolution=None)
|
|||
logger.debug(f"B: {b}")
|
||||
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()
|
||||
elif a != s and b == s:
|
||||
await _a_to_b()
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class FilesystemStorage(Storage):
|
|||
try:
|
||||
subprocess.call([self.post_hook, fpath])
|
||||
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):
|
||||
logger.info(
|
||||
|
|
@ -186,7 +186,7 @@ class FilesystemStorage(Storage):
|
|||
try:
|
||||
subprocess.call([self.pre_deletion_hook, fpath])
|
||||
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):
|
||||
fpath = os.path.join(self.path, key)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class HttpStorage(Storage):
|
|||
)
|
||||
return result.stdout
|
||||
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
|
||||
|
||||
async def list(self):
|
||||
|
|
|
|||
|
|
@ -136,9 +136,9 @@ async def sync(
|
|||
raise BothReadOnly
|
||||
|
||||
if conflict_resolution == "a wins":
|
||||
conflict_resolution = lambda a, b: a # noqa: E731
|
||||
conflict_resolution = lambda a, b: a
|
||||
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))
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def get_storage_init_specs(cls, stop_at=object):
|
|||
spec = getfullargspec(cls.__init__)
|
||||
traverse_superclass = getattr(cls.__init__, "_traverse_superclass", True)
|
||||
if traverse_superclass:
|
||||
if traverse_superclass is True: # noqa
|
||||
if traverse_superclass is True:
|
||||
supercls = next(
|
||||
getattr(x.__init__, "__objclass__", x) for x in cls.__mro__[1:]
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue