From 35b1b86df9c4f209646d98c70939db42a599a043 Mon Sep 17 00:00:00 2001
From: Joscha Schmiedt <joscha@schmiedt.dev>
Date: Sat, 20 Apr 2024 21:54:59 +0200
Subject: [PATCH] Fix newline in format string (unsupported by Python < 3.12

---
 src/linkahead/cached.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/linkahead/cached.py b/src/linkahead/cached.py
index 121e2614..eaf24da0 100644
--- a/src/linkahead/cached.py
+++ b/src/linkahead/cached.py
@@ -126,20 +126,24 @@ def _cached_access(kind: AccessType, value: Union[str, int], unique: bool = True
 
     try:
         if kind == AccessType.QUERY:
-            assert isinstance(value, str), f"If kind is QUERY, value must be a string, not {
-                type(value)}."
+            if not isinstance(value, str):
+                raise TypeError(
+                    f"If AccessType is QUERY, value must be a string, not {type(value)}.")
             return execute_query(value, unique=unique)
         if kind == AccessType.NAME:
-            assert isinstance(value, str), f"If kind is NAME, value must be a string, not {
-                type(value)}."
+            if not isinstance(value, str):
+                raise TypeError(
+                    f"If AccessType is NAME, value must be a string, not {type(value)}.")
             return get_entity.get_entity_by_name(value)
         if kind == AccessType.EID:
-            assert isinstance(value, (str, int)), f"If kind is EID, value must be a string or int, not {
-                type(value)}."
+            if not isinstance(value, (str, int)):
+                raise TypeError(
+                    f"If AccessType is EID, value must be a string or int, not {type(value)}.")
             return get_entity.get_entity_by_id(value)
         if kind == AccessType.PATH:
-            assert isinstance(value, str), f"If kind is PATH, value must be a string, not {
-                type(value)}."
+            if not isinstance(value, str):
+                raise TypeError(
+                    f"If AccessType is PATH, value must be a string, not {type(value)}.")
             return get_entity.get_entity_by_path(value)
     except (QueryNotUniqueError, EmptyUniqueQueryError) as exc:
         return exc
-- 
GitLab