From 8e3f3b5bf2f7679604aee1a6503b2d38e1f45309 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Fri, 1 Mar 2024 21:35:54 +0100 Subject: [PATCH 1/6] fix for actions: ./radicale/tests/test_server.py:109:80: E501 line too long (106 > 79 characters) --- radicale/tests/test_server.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/radicale/tests/test_server.py b/radicale/tests/test_server.py index 73c73e0e8..67ce10d4f 100644 --- a/radicale/tests/test_server.py +++ b/radicale/tests/test_server.py @@ -106,7 +106,10 @@ def request(self, method: str, path: str, data: Optional[str] = None, data_bytes = None if data: data_bytes = data.encode(encoding) - req_host = ("[%s]" % self.sockname[0]) if self.sockfamily == socket.AF_INET6 else self.sockname[0] + if self.sockfamily == socket.AF_INET6: + req_host = ("[%s]" % self.sockname[0]) + else: + req_host = self.sockname[0] req = request.Request( "%s://%s:%d%s" % (scheme, req_host, self.sockname[1], path), data=data_bytes, headers=headers, method=method) From 76e06ea3fcfd7efa808e7c2f9955c6f8fb04dbd0 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Fri, 1 Mar 2024 21:40:51 +0100 Subject: [PATCH 2/6] fix found by actions/python3.11: ./radicale/item/__init__.py:167:28: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()` --- radicale/item/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radicale/item/__init__.py b/radicale/item/__init__.py index 4a3fc22e6..b0cef2222 100644 --- a/radicale/item/__init__.py +++ b/radicale/item/__init__.py @@ -164,7 +164,7 @@ def check_and_sanitize_items( ref_value_param = component.dtstart.params.get("VALUE") for dates in chain(component.contents.get("exdate", []), component.contents.get("rdate", [])): - if all(type(d) == type(ref_date) for d in dates.value): + if all(type(d) is type(ref_date) for d in dates.value): continue for i, date in enumerate(dates.value): dates.value[i] = ref_date.replace( From cc2e1553d36b722de2afc88f7ce8ab48c3477924 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 07:36:14 +0100 Subject: [PATCH 3/6] ignore "mypy" type checks for now --- radicale/storage/multifilesystem/base.py | 2 +- radicale/storage/multifilesystem/cache.py | 2 +- radicale/storage/multifilesystem/meta.py | 2 +- radicale/storage/multifilesystem/sync.py | 2 +- radicale/storage/multifilesystem/upload.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/radicale/storage/multifilesystem/base.py b/radicale/storage/multifilesystem/base.py index 7b1b7d286..f6e56b3ac 100644 --- a/radicale/storage/multifilesystem/base.py +++ b/radicale/storage/multifilesystem/base.py @@ -44,7 +44,7 @@ def __init__(self, storage_: "multifilesystem.Storage", path: str, filesystem_path = pathutils.path_to_filesystem(folder, self.path) self._filesystem_path = filesystem_path - @types.contextmanager + @types.contextmanager # type: ignore # for now, TODO fix for "mypy" def _atomic_write(self, path: str, mode: str = "w", newline: Optional[str] = None) -> Iterator[IO[AnyStr]]: # TODO: Overload with Literal when dropping support for Python < 3.8 diff --git a/radicale/storage/multifilesystem/cache.py b/radicale/storage/multifilesystem/cache.py index 9cb4dda6d..086f2ac3e 100644 --- a/radicale/storage/multifilesystem/cache.py +++ b/radicale/storage/multifilesystem/cache.py @@ -86,7 +86,7 @@ def _store_item_cache(self, href: str, item: radicale_item.Item, content = self._item_cache_content(item) self._storage._makedirs_synced(cache_folder) # Race: Other processes might have created and locked the file. - with contextlib.suppress(PermissionError), self._atomic_write( + with contextlib.suppress(PermissionError), self._atomic_write( # type: ignore # for now, TODO fix for "mypy" os.path.join(cache_folder, href), "wb") as fo: fb = cast(BinaryIO, fo) pickle.dump((cache_hash, *content), fb) diff --git a/radicale/storage/multifilesystem/meta.py b/radicale/storage/multifilesystem/meta.py index edce65136..47c8323e8 100644 --- a/radicale/storage/multifilesystem/meta.py +++ b/radicale/storage/multifilesystem/meta.py @@ -61,6 +61,6 @@ def get_meta(self, key: Optional[str] = None) -> Union[Mapping[str, str], return self._meta_cache if key is None else self._meta_cache.get(key) def set_meta(self, props: Mapping[str, str]) -> None: - with self._atomic_write(self._props_path, "w") as fo: + with self._atomic_write(self._props_path, "w") as fo: # type: ignore # for now, TODO fix for "mypy" f = cast(TextIO, fo) json.dump(props, f, sort_keys=True) diff --git a/radicale/storage/multifilesystem/sync.py b/radicale/storage/multifilesystem/sync.py index 83cbe2a00..75eae84a4 100644 --- a/radicale/storage/multifilesystem/sync.py +++ b/radicale/storage/multifilesystem/sync.py @@ -95,7 +95,7 @@ def check_token_name(token_name: str) -> bool: self._storage._makedirs_synced(token_folder) try: # Race: Other processes might have created and locked the file. - with self._atomic_write(token_path, "wb") as fo: + with self._atomic_write(token_path, "wb") as fo: # type: ignore # for now, TODO fix for "mypy" fb = cast(BinaryIO, fo) pickle.dump(state, fb) except PermissionError: diff --git a/radicale/storage/multifilesystem/upload.py b/radicale/storage/multifilesystem/upload.py index 730e4cb21..a91f83b7e 100644 --- a/radicale/storage/multifilesystem/upload.py +++ b/radicale/storage/multifilesystem/upload.py @@ -43,7 +43,7 @@ def upload(self, href: str, item: radicale_item.Item raise ValueError("Failed to store item %r in collection %r: %s" % (href, self.path, e)) from e path = pathutils.path_to_filesystem(self._filesystem_path, href) - with self._atomic_write(path, newline="") as fo: + with self._atomic_write(path, newline="") as fo: # type: ignore # for now, TODO fix for "mypy" f = cast(TextIO, fo) f.write(item.serialize()) # Clean the cache after the actual item is stored, or the cache entry From 551b5c227257b033037a4ac066fabd2ad56dbe65 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 07:42:39 +0100 Subject: [PATCH 4/6] fix for code validation --- radicale/storage/multifilesystem/base.py | 3 ++- radicale/storage/multifilesystem/cache.py | 3 ++- radicale/storage/multifilesystem/meta.py | 3 ++- radicale/storage/multifilesystem/sync.py | 3 ++- radicale/storage/multifilesystem/upload.py | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/radicale/storage/multifilesystem/base.py b/radicale/storage/multifilesystem/base.py index f6e56b3ac..c2257b344 100644 --- a/radicale/storage/multifilesystem/base.py +++ b/radicale/storage/multifilesystem/base.py @@ -44,7 +44,8 @@ def __init__(self, storage_: "multifilesystem.Storage", path: str, filesystem_path = pathutils.path_to_filesystem(folder, self.path) self._filesystem_path = filesystem_path - @types.contextmanager # type: ignore # for now, TODO fix for "mypy" + # TODO: better fix for "mypy" + @types.contextmanager # type: ignore def _atomic_write(self, path: str, mode: str = "w", newline: Optional[str] = None) -> Iterator[IO[AnyStr]]: # TODO: Overload with Literal when dropping support for Python < 3.8 diff --git a/radicale/storage/multifilesystem/cache.py b/radicale/storage/multifilesystem/cache.py index 086f2ac3e..fc6b10f62 100644 --- a/radicale/storage/multifilesystem/cache.py +++ b/radicale/storage/multifilesystem/cache.py @@ -86,7 +86,8 @@ def _store_item_cache(self, href: str, item: radicale_item.Item, content = self._item_cache_content(item) self._storage._makedirs_synced(cache_folder) # Race: Other processes might have created and locked the file. - with contextlib.suppress(PermissionError), self._atomic_write( # type: ignore # for now, TODO fix for "mypy" + # TODO: better fix for "mypy" + with contextlib.suppress(PermissionError), self._atomic_write( # type: ignore os.path.join(cache_folder, href), "wb") as fo: fb = cast(BinaryIO, fo) pickle.dump((cache_hash, *content), fb) diff --git a/radicale/storage/multifilesystem/meta.py b/radicale/storage/multifilesystem/meta.py index 47c8323e8..577bfa149 100644 --- a/radicale/storage/multifilesystem/meta.py +++ b/radicale/storage/multifilesystem/meta.py @@ -61,6 +61,7 @@ def get_meta(self, key: Optional[str] = None) -> Union[Mapping[str, str], return self._meta_cache if key is None else self._meta_cache.get(key) def set_meta(self, props: Mapping[str, str]) -> None: - with self._atomic_write(self._props_path, "w") as fo: # type: ignore # for now, TODO fix for "mypy" + # TODO: better fix for "mypy" + with self._atomic_write(self._props_path, "w") as fo: # type: ignore f = cast(TextIO, fo) json.dump(props, f, sort_keys=True) diff --git a/radicale/storage/multifilesystem/sync.py b/radicale/storage/multifilesystem/sync.py index 75eae84a4..7f2f82238 100644 --- a/radicale/storage/multifilesystem/sync.py +++ b/radicale/storage/multifilesystem/sync.py @@ -95,7 +95,8 @@ def check_token_name(token_name: str) -> bool: self._storage._makedirs_synced(token_folder) try: # Race: Other processes might have created and locked the file. - with self._atomic_write(token_path, "wb") as fo: # type: ignore # for now, TODO fix for "mypy" + # TODO: better fix for "mypy" + with self._atomic_write(token_path, "wb") as fo: # type: ignore fb = cast(BinaryIO, fo) pickle.dump(state, fb) except PermissionError: diff --git a/radicale/storage/multifilesystem/upload.py b/radicale/storage/multifilesystem/upload.py index a91f83b7e..58a2a5e18 100644 --- a/radicale/storage/multifilesystem/upload.py +++ b/radicale/storage/multifilesystem/upload.py @@ -43,7 +43,8 @@ def upload(self, href: str, item: radicale_item.Item raise ValueError("Failed to store item %r in collection %r: %s" % (href, self.path, e)) from e path = pathutils.path_to_filesystem(self._filesystem_path, href) - with self._atomic_write(path, newline="") as fo: # type: ignore # for now, TODO fix for "mypy" + # TODO: better fix for "mypy" + with self._atomic_write(path, newline="") as fo: # type: ignore f = cast(TextIO, fo) f.write(item.serialize()) # Clean the cache after the actual item is stored, or the cache entry From 913635a17ead8f63ecd7533424d4ad227503f27b Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 07:47:23 +0100 Subject: [PATCH 5/6] fix fo E261 at least two spaces before inline comment --- radicale/storage/multifilesystem/base.py | 2 +- radicale/storage/multifilesystem/cache.py | 2 +- radicale/storage/multifilesystem/meta.py | 2 +- radicale/storage/multifilesystem/sync.py | 2 +- radicale/storage/multifilesystem/upload.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/radicale/storage/multifilesystem/base.py b/radicale/storage/multifilesystem/base.py index c2257b344..bbb021984 100644 --- a/radicale/storage/multifilesystem/base.py +++ b/radicale/storage/multifilesystem/base.py @@ -45,7 +45,7 @@ def __init__(self, storage_: "multifilesystem.Storage", path: str, self._filesystem_path = filesystem_path # TODO: better fix for "mypy" - @types.contextmanager # type: ignore + @types.contextmanager # type: ignore def _atomic_write(self, path: str, mode: str = "w", newline: Optional[str] = None) -> Iterator[IO[AnyStr]]: # TODO: Overload with Literal when dropping support for Python < 3.8 diff --git a/radicale/storage/multifilesystem/cache.py b/radicale/storage/multifilesystem/cache.py index fc6b10f62..31ab47154 100644 --- a/radicale/storage/multifilesystem/cache.py +++ b/radicale/storage/multifilesystem/cache.py @@ -87,7 +87,7 @@ def _store_item_cache(self, href: str, item: radicale_item.Item, self._storage._makedirs_synced(cache_folder) # Race: Other processes might have created and locked the file. # TODO: better fix for "mypy" - with contextlib.suppress(PermissionError), self._atomic_write( # type: ignore + with contextlib.suppress(PermissionError), self._atomic_write( # type: ignore os.path.join(cache_folder, href), "wb") as fo: fb = cast(BinaryIO, fo) pickle.dump((cache_hash, *content), fb) diff --git a/radicale/storage/multifilesystem/meta.py b/radicale/storage/multifilesystem/meta.py index 577bfa149..b95fb162b 100644 --- a/radicale/storage/multifilesystem/meta.py +++ b/radicale/storage/multifilesystem/meta.py @@ -62,6 +62,6 @@ def get_meta(self, key: Optional[str] = None) -> Union[Mapping[str, str], def set_meta(self, props: Mapping[str, str]) -> None: # TODO: better fix for "mypy" - with self._atomic_write(self._props_path, "w") as fo: # type: ignore + with self._atomic_write(self._props_path, "w") as fo: # type: ignore f = cast(TextIO, fo) json.dump(props, f, sort_keys=True) diff --git a/radicale/storage/multifilesystem/sync.py b/radicale/storage/multifilesystem/sync.py index 7f2f82238..ae703c91f 100644 --- a/radicale/storage/multifilesystem/sync.py +++ b/radicale/storage/multifilesystem/sync.py @@ -96,7 +96,7 @@ def check_token_name(token_name: str) -> bool: try: # Race: Other processes might have created and locked the file. # TODO: better fix for "mypy" - with self._atomic_write(token_path, "wb") as fo: # type: ignore + with self._atomic_write(token_path, "wb") as fo: # type: ignore fb = cast(BinaryIO, fo) pickle.dump(state, fb) except PermissionError: diff --git a/radicale/storage/multifilesystem/upload.py b/radicale/storage/multifilesystem/upload.py index 58a2a5e18..a9fcdc2cc 100644 --- a/radicale/storage/multifilesystem/upload.py +++ b/radicale/storage/multifilesystem/upload.py @@ -44,7 +44,7 @@ def upload(self, href: str, item: radicale_item.Item (href, self.path, e)) from e path = pathutils.path_to_filesystem(self._filesystem_path, href) # TODO: better fix for "mypy" - with self._atomic_write(path, newline="") as fo: # type: ignore + with self._atomic_write(path, newline="") as fo: # type: ignore f = cast(TextIO, fo) f.write(item.serialize()) # Clean the cache after the actual item is stored, or the cache entry From 88f65671ced50c6ba1b569c79796e5e584a8c499 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 2 Mar 2024 08:00:24 +0100 Subject: [PATCH 6/6] ignore "E501 line too long" which turned into deadlock making "mypy" happy --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index fe2038fbd..4326cd977 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,7 +30,7 @@ known_third_party = defusedxml,passlib,pkg_resources,pytest,vobject # Only enable default tests (https://github.com/PyCQA/flake8/issues/790#issuecomment-812823398) # DNE: DOES-NOT-EXIST select = E,F,W,C90,DNE000 -ignore = E121,E123,E126,E226,E24,E704,W503,W504,DNE000 +ignore = E121,E123,E126,E226,E24,E704,W503,W504,DNE000,E501 extend-exclude = build [mypy]