about summary refs log tree commit diff
path: root/pkgs/by-name/ki
diff options
context:
space:
mode:
authoreljamm <fedi.jamoussi@protonmail.ch>2024-05-31 17:05:24 +0100
committereljamm <fedi.jamoussi@protonmail.ch>2024-05-31 17:08:00 +0100
commit95016007bf71b2cb3be2abc368f8af481dd8ef25 (patch)
tree792d3e4120b578bddc06ddb23a30d05124121334 /pkgs/by-name/ki
parent4a9b788bf5d4bb1016770b7639411aafbcb7991c (diff)
ki: fix beartype error and format with nixfmt
The `copy_note_media` function wrongly returns a `Frozenset` instead of
a `Set`, which raises an error for the newest beartype version (v0.18.5)
Diffstat (limited to 'pkgs/by-name/ki')
-rw-r--r--pkgs/by-name/ki/ki/fix-beartype-error.patch38
-rw-r--r--pkgs/by-name/ki/ki/package.nix38
2 files changed, 58 insertions, 18 deletions
diff --git a/pkgs/by-name/ki/ki/fix-beartype-error.patch b/pkgs/by-name/ki/ki/fix-beartype-error.patch
new file mode 100644
index 0000000000000..7f13488e4e0a0
--- /dev/null
+++ b/pkgs/by-name/ki/ki/fix-beartype-error.patch
@@ -0,0 +1,38 @@
+From bd765844b40f88547a2afe90d0e09bf74ff0bd61 Mon Sep 17 00:00:00 2001
+From: eljamm <fedi.jamoussi@protonmail.ch>
+Date: Fri, 31 May 2024 16:48:06 +0100
+Subject: [PATCH] Fix beartype Frozenset error
+
+The `copy_note_media` function wrongly returns a `Frozenset` instead of
+a `Set`, which raises an error for the newest beartype version (v0.18.5)
+---
+ ki/__init__.py | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/ki/__init__.py b/ki/__init__.py
+index 3f29c1a..cc65fae 100644
+--- a/ki/__init__.py
++++ b/ki/__init__.py
+@@ -752,9 +752,7 @@ def media_filenames_in_field(col: Collection, s: str) -> Iterable[str]:
+ 
+ @curried
+ @beartype
+-def copy_note_media(
+-    col: Collection, src: Dir, tgt: Dir, row: NoteDBRow
+-) -> FrozenSet[File]:
++def copy_note_media(col: Collection, src: Dir, tgt: Dir, row: NoteDBRow) -> Set[File]:
+     """
+     Copy a single note's media files and return the copies as a set. We do this
+     by first filtering for only 'rootfiles', i.e. excluding media files in
+@@ -769,7 +767,7 @@ def copy_note_media(
+     rootfiles = filter(lambda f: f == os.path.basename(f), files)
+     medias: Iterable[File] = filter(F.isfile, map(lambda f: F.chk(src / f), rootfiles))
+     srcdsts = map(lambda file: (file, F.chk(tgt / file.name)), medias)
+-    return frozenset(starmap(F.copyfile, srcdsts))
++    return set(starmap(F.copyfile, srcdsts))
+ 
+ 
+ @curried
+-- 
+2.44.1
+
diff --git a/pkgs/by-name/ki/ki/package.nix b/pkgs/by-name/ki/ki/package.nix
index 549f60acd8bf1..e4d95d64234bc 100644
--- a/pkgs/by-name/ki/ki/package.nix
+++ b/pkgs/by-name/ki/ki/package.nix
@@ -1,8 +1,9 @@
-{ lib
-, fetchFromGitHub
-, python3Packages
-, cmake
-, anki
+{
+  lib,
+  fetchFromGitHub,
+  python3Packages,
+  cmake,
+  anki,
 }:
 
 python3Packages.buildPythonApplication rec {
@@ -21,24 +22,25 @@ python3Packages.buildPythonApplication rec {
   };
 
   patches = [
-    ./update-to-newer-anki-versions.patch
+    ./fix-beartype-error.patch
     ./replace-deprecated-distutils-with-setuptools.patch
+    ./update-to-newer-anki-versions.patch
   ];
 
   nativeBuildInputs = [ cmake ];
 
-  propagatedBuildInputs = with python3Packages; [
-    beartype
-    click
-    colorama
-    git-filter-repo
-    gitpython
-    lark
-    tqdm
-    whatthepatch
-  ] ++ [
-    anki
-  ];
+  propagatedBuildInputs =
+    [ anki ]
+    ++ (with python3Packages; [
+      beartype
+      click
+      colorama
+      git-filter-repo
+      gitpython
+      lark
+      tqdm
+      whatthepatch
+    ]);
 
   nativeCheckInputs = with python3Packages; [
     bitstring