def get_type(self, type_name):
type_name = self._canonicalize_type(type_name)<EOL>if str(type_name) == '<STR_LIT:int>':<EOL><INDENT>type_name = '<STR_LIT>'<EOL><DEDENT>elif str(type_name) == '<STR_LIT:str>':<EOL><INDENT>type_name = '<STR_LIT:string>'<EOL><DEDENT>elif str(type_name) == '<STR_LIT>':<EOL><INDENT>type_name = '<STR_LIT>'<EOL><DEDENT>if self.is_known_type(type_name):<EOL><INDENT>return self.known_types[type_name]<EOL><DEDENT>base_type, is_complex, subtypes = self.split_type(type_name)<EOL>if is_complex and base_type in self.type_factories:<EOL><INDENT>self.instantiate_type(type_name, base_type, subtypes)<EOL>return self.known_types[type_name]<EOL><DEDENT>i = <NUM_LIT:0><EOL>for i, (source, name) in enumerate(self._lazy_type_sources):<EOL><INDENT>if isinstance(source, str):<EOL><INDENT>import pkg_resources<EOL>for entry in pkg_resources.iter_entry_points(source):<EOL><INDENT>try:<EOL><INDENT>mod = entry.load()<EOL>type_system.load_type_module(mod)<EOL><DEDENT>except:  <EOL><INDENT>fail_info = ("<STR_LIT>" % (source, entry.name), sys.exc_info)<EOL>logging.exception("<STR_LIT>", source, entry.name)<EOL>self.failed_sources.append(fail_info)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>source(self)<EOL><DEDENT>except:  <EOL><INDENT>fail_info = ("<STR_LIT>" % name, sys.exc_info)<EOL>logging.exception("<STR_LIT>", source)<EOL>self.failed_sources.append(fail_info)<EOL><DEDENT><DEDENT>if self.is_known_type(type_name) or (is_complex and base_type in self.type_factories):<EOL><INDENT>break<EOL><DEDENT><DEDENT>self._lazy_type_sources = self._lazy_type_sources[i:]<EOL>if not (self.is_known_type(type_name) or (is_complex and base_type in self.type_factories)):<EOL><INDENT>raise ArgumentError("<STR_LIT>", type=type_name, failed_external_sources=[x[<NUM_LIT:0>] for x in self.failed_sources])<EOL><DEDENT>return self.get_type(type_name)<EOL>
Return the type object corresponding to a type name.

        If type_name is not found, this triggers the loading of
        external types until a matching type is found or until there
        are no more external type sources.