@staticmethod<EOL><INDENT>def infer_list_subtype(items):<DEDENT>
subtype = End<EOL>for item in items:<EOL><INDENT>item_type = type(item)<EOL>if not issubclass(item_type, Base):<EOL><INDENT>continue<EOL><DEDENT>if subtype is End:<EOL><INDENT>subtype = item_type<EOL>if not issubclass(subtype, List):<EOL><INDENT>return subtype<EOL><DEDENT><DEDENT>elif subtype is not item_type:<EOL><INDENT>stype, itype = subtype, item_type<EOL>generic = List<EOL>while issubclass(stype, List) and issubclass(itype, List):<EOL><INDENT>stype, itype = stype.subtype, itype.subtype<EOL>generic = List[generic]<EOL><DEDENT>if stype is End:<EOL><INDENT>subtype = item_type<EOL><DEDENT>elif itype is not End:<EOL><INDENT>return generic.subtype<EOL><DEDENT><DEDENT><DEDENT>return subtype<EOL>
Infer a list subtype from a collection of items.