@@ -1195,7 +1195,7 @@ def gen_condition(self) -> None:
11951195 def check_type (obj : Any , typ : type [Any ]) -> bool :
11961196 # ForEnumerate gen_condition is as fast as it's underlying generator's
11971197 return (
1198- isinstance (obj , typ ) or isinstance (obj , ForEnumerate ) and isinstance (obj .gen , typ )
1198+ isinstance (obj , typ ) or isinstance (obj , ForEnumerate ) and isinstance (obj .main_gen , typ )
11991199 )
12001200
12011201 # these are slowest, they invoke Python's iteration protocol
@@ -1213,28 +1213,28 @@ def check_type(obj: Any, typ: type[Any]) -> bool:
12131213 g
12141214 for g in gens
12151215 if check_type (g , ForSequence )
1216- and (for_seq := ( g . gen if isinstance (g , ForEnumerate ) else g )).reverse
1216+ and (for_seq := cast ( ForSequence , g . main_gen if isinstance (g , ForEnumerate ) else g ) )).reverse
12171217 and for_seq .len_reg is not None
12181218 ]
12191219 for_sequence_reverse_no_len_check = [
12201220 g
12211221 for g in gens
12221222 if check_type (g , ForSequence )
1223- and (for_seq := ( g . gen if isinstance (g , ForEnumerate ) else g )).reverse
1223+ and (for_seq := cast ( ForSequence , g . main_gen if isinstance (g , ForEnumerate ) else g )).reverse
12241224 and for_seq .len_reg is None
12251225 ]
12261226 for_sequence_forward_with_len_check = [
12271227 g
12281228 for g in gens
12291229 if check_type (g , ForSequence )
1230- and not (for_seq := ( g . gen if isinstance (g , ForEnumerate ) else g )).reverse
1230+ and not (for_seq := cast ( ForSequence , g . main_gen if isinstance (g , ForEnumerate ) else g )).reverse
12311231 and for_seq .len_reg is not None
12321232 ]
12331233 for_sequence_forward_no_len_check = [
12341234 g
12351235 for g in gens
12361236 if check_type (g , ForSequence )
1237- and not (for_seq := ( g . gen if isinstance (g , ForEnumerate ) else g )).reverse
1237+ and not (for_seq := cast ( ForSequence , g . main_gen if isinstance (g , ForEnumerate ) else g )).reverse
12381238 and for_seq .len_reg is None
12391239 ]
12401240
0 commit comments