@@ -570,7 +570,9 @@ def _make_cached_property_uncached(original_cached_property_func, cls):
570570 doc_lines .append ("\n " )
571571 doc_lines .append ('"""' )
572572
573- annotation = inspect .signature (original_cached_property_func ).return_annotation
573+ annotation = inspect .signature (
574+ original_cached_property_func
575+ ).return_annotation
574576 if annotation is inspect .Parameter .empty :
575577 defline = f"def { name } (self):"
576578 elif isinstance (annotation , str ):
@@ -579,9 +581,14 @@ def _make_cached_property_uncached(original_cached_property_func, cls):
579581 try :
580582 import annotationlib
581583
582- defline = f"def { name } (self) -> { annotationlib .type_repr (annotation )} :"
584+ defline = (
585+ f"def { name } (self) -> { annotationlib .type_repr (annotation )} :"
586+ )
583587 except ModuleNotFoundError :
584- if isinstance (annotation , (type , types .FunctionType , types .BuiltinFunctionType )):
588+ if isinstance (
589+ annotation ,
590+ (type , types .FunctionType , types .BuiltinFunctionType ),
591+ ):
585592 if annotation .__module__ == "builtins" :
586593 defline = f"def { name } (self) -> { annotation .__qualname__ } :"
587594 else :
@@ -594,11 +601,15 @@ def _make_cached_property_uncached(original_cached_property_func, cls):
594601 "@property" ,
595602 defline ,
596603 * (" " + line for line in doc_lines ),
597- f " raise AttributeError('Use __getattr__ instead')"
604+ " raise AttributeError('Use __getattr__ instead')" ,
598605 ]
599- unique_filename = _generate_unique_filename (cls , original_cached_property_func )
606+ unique_filename = _generate_unique_filename (
607+ cls , original_cached_property_func
608+ )
600609 glob = {"original_cached_property" : original_cached_property_func }
601- return _linecache_and_compile ("\n " .join (lines ), unique_filename , glob )[name ]
610+ return _linecache_and_compile ("\n " .join (lines ), unique_filename , glob )[
611+ name
612+ ]
602613
603614
604615def _frozen_setattrs (self , name , value ):
@@ -968,7 +979,7 @@ def _create_slots_class(self):
968979 class_annotations = _get_annotations (self ._cls )
969980 for name , func in cached_properties .items ():
970981 # Add cached properties to names for slotting.
971- names += (name + ' _cache' ,)
982+ names += (name + " _cache" ,)
972983 # Clear out function from class to avoid clashing.
973984 del cd [name ]
974985 additional_closure_functions_to_update .append (func )
0 commit comments