diff --git a/tests/storage/dav/test_main.py b/tests/storage/dav/test_main.py index 4fa875d..9b9174a 100644 --- a/tests/storage/dav/test_main.py +++ b/tests/storage/dav/test_main.py @@ -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): diff --git a/tests/storage/servers/davical/__init__.py b/tests/storage/servers/davical/__init__.py index b3af413..df4f8ab 100644 --- a/tests/storage/servers/davical/__init__.py +++ b/tests/storage/servers/davical/__init__.py @@ -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) diff --git a/tests/storage/servers/icloud/__init__.py b/tests/storage/servers/icloud/__init__.py index eb6af67..028adcc 100644 --- a/tests/storage/servers/icloud/__init__.py +++ b/tests/storage/servers/icloud/__init__.py @@ -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"): diff --git a/tests/system/cli/test_discover.py b/tests/system/cli/test_discover.py index a50b56a..1bb9f71 100644 --- a/tests/system/cli/test_discover.py +++ b/tests/system/cli/test_discover.py @@ -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" """ ) ) diff --git a/tests/system/cli/test_fetchparams.py b/tests/system/cli/test_fetchparams.py index af257b0..c0db24b 100644 --- a/tests/system/cli/test_fetchparams.py +++ b/tests/system/cli/test_fetchparams.py @@ -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"] """ ) diff --git a/tests/system/cli/test_sync.py b/tests/system/cli/test_sync.py index 77a512a..78b1362 100644 --- a/tests/system/cli/test_sync.py +++ b/tests/system/cli/test_sync.py @@ -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" """ ) diff --git a/tests/unit/utils/test_vobject.py b/tests/unit/utils/test_vobject.py index d656129..616cbb2 100644 --- a/tests/unit/utils/test_vobject.py +++ b/tests/unit/utils/test_vobject.py @@ -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 diff --git a/vdirsyncer/__init__.py b/vdirsyncer/__init__.py index e98d7ad..9abc39c 100644 --- a/vdirsyncer/__init__.py +++ b/vdirsyncer/__init__.py @@ -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) diff --git a/vdirsyncer/cli/config.py b/vdirsyncer/cli/config.py index ccc7bc6..7314daa 100644 --- a/vdirsyncer/cli/config.py +++ b/vdirsyncer/cli/config.py @@ -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): diff --git a/vdirsyncer/cli/fetchparams.py b/vdirsyncer/cli/fetchparams.py index 79e9c98..2916f9d 100644 --- a/vdirsyncer/cli/fetchparams.py +++ b/vdirsyncer/cli/fetchparams.py @@ -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): diff --git a/vdirsyncer/metasync.py b/vdirsyncer/metasync.py index 1d34dd2..cc5052c 100644 --- a/vdirsyncer/metasync.py +++ b/vdirsyncer/metasync.py @@ -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() diff --git a/vdirsyncer/storage/filesystem.py b/vdirsyncer/storage/filesystem.py index 3ab5113..71b185d 100644 --- a/vdirsyncer/storage/filesystem.py +++ b/vdirsyncer/storage/filesystem.py @@ -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) diff --git a/vdirsyncer/storage/http.py b/vdirsyncer/storage/http.py index 7ce891b..40dbc25 100644 --- a/vdirsyncer/storage/http.py +++ b/vdirsyncer/storage/http.py @@ -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): diff --git a/vdirsyncer/sync/__init__.py b/vdirsyncer/sync/__init__.py index 8b24219..e8db4d1 100644 --- a/vdirsyncer/sync/__init__.py +++ b/vdirsyncer/sync/__init__.py @@ -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)) diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index 2d4b5f2..0d5a47e 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -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:] )