@@ -84,9 +84,8 @@ def keygetter(
8484 dct = dct [sub_field ]
8585 elif hasattr (dct , sub_field ):
8686 dct = getattr (dct , sub_field )
87- except Exception as e :
87+ except Exception :
8888 traceback .print_stack ()
89- print (f"Above error was { e } " )
9089 return None
9190 return dct
9291
@@ -304,12 +303,12 @@ def lookup_iregex(
304303
305304
306305class PKRequiredException (Exception ):
307- def __init__ (self , * args : object ):
306+ def __init__ (self , * args : object ) -> None :
308307 return super ().__init__ ("items() require a pk_key exists" )
309308
310309
311310class OpNotFound (ValueError ):
312- def __init__ (self , op : str , * args : object ):
311+ def __init__ (self , op : str , * args : object ) -> None :
313312 return super ().__init__ (f"{ op } not in LOOKUP_NAME_MAP" )
314313
315314
@@ -470,7 +469,7 @@ def __init__(self, items: t.Optional["Iterable[T]"] = None) -> None:
470469
471470 def items (self ) -> list [tuple [str , T ]]:
472471 if self .pk_key is None :
473- raise PKRequiredException ()
472+ raise PKRequiredException
474473 return [(getattr (item , self .pk_key ), item ) for item in self ]
475474
476475 def __eq__ (
@@ -490,9 +489,8 @@ def __eq__(
490489 for key in a_keys :
491490 if abs (a [key ] - b [key ]) > 1 :
492491 return False
493- else :
494- if a != b :
495- return False
492+ elif a != b :
493+ return False
496494
497495 return True
498496 return False
@@ -529,8 +527,7 @@ def filter_lookup(obj: t.Any) -> bool:
529527 def val_match (obj : t .Union [str , list [t .Any ], T ]) -> bool :
530528 if isinstance (matcher , list ):
531529 return obj in matcher
532- else :
533- return bool (obj == matcher )
530+ return bool (obj == matcher )
534531
535532 _filter = val_match
536533 else :
@@ -546,9 +543,9 @@ def get(
546543 ) -> t .Optional [T ]:
547544 objs = self .filter (matcher = matcher , ** kwargs )
548545 if len (objs ) > 1 :
549- raise MultipleObjectsReturned ()
550- elif len (objs ) == 0 :
546+ raise MultipleObjectsReturned
547+ if len (objs ) == 0 :
551548 if default == no_arg :
552- raise ObjectDoesNotExist ()
549+ raise ObjectDoesNotExist
553550 return default
554551 return objs [0 ]
0 commit comments