Decorator for mutation tracker registration.

        The provided `origin_type` is mapped to the decorated class such that
        future calls to `convert()` will convert the object of `origin_type`
        to an instance of the decorated class.
768713
def register(cls, origin_type):
        
        def decorator(tracked_type):
            """Adds the decorated class to the `_type_mapping` dictionary."""
            cls._type_mapping[origin_type] = tracked_type
            return tracked_type
        return decorator
869018
def apply_ir_heuristics(irs, node):
    

    irs = integrate_value_gas(irs)

    irs = propagate_type_and_convert_call(irs, node)
    irs = remove_unused(irs)
    find_references_origin(irs)


    return irs
1286053
def convert_type(self, type):
        

        # Mapping
        mapping = {
            'any': 'STRING',
            'array': None,
            'boolean': 'BOOLEAN',
            'date': 'DATE',
            'datetime': 'DATETIME',
            'duration': None,
            'geojson': None,
            'geopoint': None,
            'integer': 'INTEGER',
            'number': 'FLOAT',
            'object': None,
            'string': 'STRING',
            'time': 'TIME',
            'year': 'INTEGER',
            'yearmonth': None,
        }

        # Not supported type
        if type not in mapping:
            message = 'Type %s is not supported' % type
            raise tableschema.exceptions.StorageError(message)

        return mapping[type]
656665
def create(converter_func: ConversionMethod, caught: Exception):
        
        msg = 'Caught TypeError while calling conversion function \'' + str(converter_func.__name__) + '\'. ' \
              'Note that the conversion function signature should be \'' + conversion_method_example_signature_str \
              + '\' (unpacked options mode - default) or ' + multioptions_conversion_method_example_signature_str \
              + ' (unpack_options = False).' \
              + 'Caught error message is : ' + caught.__class__.__name__ + ' : ' + str(caught)
        return CaughtTypeError(msg).with_traceback(caught.__traceback__)
238137
def _get_func(cls, source_ver, target_ver):
		
		matches = (
			func for func in cls._upgrade_funcs
			if func.source == source_ver and func.target == target_ver
		)
		try:
			match, = matches
		except ValueError:
			raise ValueError(
				f"No migration from {source_ver} to {target_ver}")
		return match
1373982
def typelogged_func(func):
    
    if not pytypes.typelogging_enabled:
        return func
    if hasattr(func, 'do_logging'):
        func.do_logging = True
        return func
    elif hasattr(func, 'do_typecheck'):
        # actually shouldn't happen
        return _typeinspect_func(func, func.do_typecheck, True)
    else:
        return _typeinspect_func(func, False, True)
949304
def astype(self, type_name):
        
        if type_name == 'nddata':
            return self.as_nddata()

        if type_name == 'hdu':
            return self.as_hdu()

        raise ValueError("Unrecognized conversion type '%s'" % (type_name))
751081
def _find_Generic_super_origin(subclass, superclass_origin):
    
    stack = [subclass]
    param_map = {}
    while len(stack) > 0:
        bs = stack.pop()
        if is_Generic(bs):
            if not bs.__origin__ is None and len(bs.__origin__.__parameters__) > 0:
                for i in range(len(bs.__args__)):
                    ors = bs.__origin__.__parameters__[i]
                    if bs.__args__[i] != ors and isinstance(bs.__args__[i], TypeVar):
                        param_map[ors] = bs.__args__[i]
            if (bs.__origin__ is superclass_origin or \
                    (bs.__origin__ is None and bs is superclass_origin)):
                prms = []
                try:
                    if len(bs.__origin__.__parameters__) > len(bs.__parameters__):
                        prms.extend(bs.__origin__.__parameters__)
                    else:
                        prms.extend(bs.__parameters__)
                except:
                    prms.extend(bs.__parameters__)
                for i in range(len(prms)):
                    while prms[i] in param_map:
                        prms[i] = param_map[prms[i]]
                return prms
            try:
                stack.extend(bs.__orig_bases__)
            except AttributeError:
                stack.extend(bs.__bases__)
    return None
201567
def register_default_plugins(root_parser: ParserRegistryWithConverters):
    
    # -------------------- CORE ---------------------------
    try:
        # -- primitive types
        from parsyfiles.plugins_base.support_for_primitive_types import get_default_primitive_parsers, \
            get_default_primitive_converters
        root_parser.register_parsers(get_default_primitive_parsers())
        root_parser.register_converters(get_default_primitive_converters())
    except ImportError as e:
        warn_import_error('primitive types', e)
    try:
        # -- collections
        from parsyfiles.plugins_base.support_for_collections import get_default_collection_parsers, \
            get_default_collection_converters
        root_parser.register_parsers(get_default_collection_parsers(root_parser, root_parser))
        root_parser.register_converters(get_default_collection_converters(root_parser))
    except ImportError as e:
        warn_import_error('dict', e)
    try:
        # -- objects
        from parsyfiles.plugins_base.support_for_objects import get_default_object_parsers, \
            get_default_object_converters
        root_parser.register_parsers(get_default_object_parsers(root_parser, root_parser))
        root_parser.register_converters(get_default_object_converters(root_parser))
    except ImportError as e:
        warn_import_error('objects', e)
    try:
        # -- config
        from parsyfiles.plugins_base.support_for_configparser import get_default_config_parsers, \
            get_default_config_converters
        root_parser.register_parsers(get_default_config_parsers())
        root_parser.register_converters(get_default_config_converters(root_parser))
    except ImportError as e:
        warn_import_error('config', e)

    # ------------------------- OPTIONAL -----------------
    try:
        # -- jprops
        from parsyfiles.plugins_optional.support_for_jprops import get_default_jprops_parsers
        root_parser.register_parsers(get_default_jprops_parsers(root_parser, root_parser))
        # root_parser.register_converters()
    except ImportError as e:
        warn_import_error('jprops', e)
    try:
        # -- yaml
        from parsyfiles.plugins_optional.support_for_yaml import get_default_yaml_parsers
        root_parser.register_parsers(get_default_yaml_parsers(root_parser, root_parser))
        # root_parser.register_converters()
    except ImportError as e:
        warn_import_error('yaml', e)
    try:
        # -- numpy
        from parsyfiles.plugins_optional.support_for_numpy import get_default_np_parsers, get_default_np_converters
        root_parser.register_parsers(get_default_np_parsers())
        root_parser.register_converters(get_default_np_converters())
    except ImportError as e:
        warn_import_error('numpy', e)
    try:
        # -- pandas
        from parsyfiles.plugins_optional.support_for_pandas import get_default_pandas_parsers, \
            get_default_pandas_converters
        root_parser.register_parsers(get_default_pandas_parsers())
        root_parser.register_converters(get_default_pandas_converters())
    except ImportError as e:
        warn_import_error('pandas', e)
628616
def register_converter(self, converter: Converter[S, T]):
        
        check_var(converter, var_types=Converter, var_name='converter')

        # (0) sanity check : check that parser handles jokers properly
        res = converter.is_able_to_convert_detailed(from_type=JOKER, to_type=JOKER, strict=True)
        if not (res[0] is True and res[1] is None and res[2] is None):
            raise ValueError('Converter ' + str(converter) + ' can not be registered since it does not handle the JOKER'
                             ' cases correctly')

        # compute all possible chains and save them
        generic_chains, generic_nonstrict_chains, specific_chains, specific_nonstrict_chains \
            = self._create_all_new_chains(converter)
        self._generic_nonstrict_conversion_chains += generic_nonstrict_chains
        self._generic_conversion_chains += generic_chains
        self._specific_non_strict_conversion_chains += specific_nonstrict_chains
        self._specific_conversion_chains += specific_chains

        # sort all lists by length
        self._generic_nonstrict_conversion_chains = sorted(self._generic_nonstrict_conversion_chains, key=len,
                                                           reverse=True)
        self._generic_conversion_chains = sorted(self._generic_conversion_chains, key=len, reverse=True)
        self._specific_non_strict_conversion_chains = sorted(self._specific_non_strict_conversion_chains, key=len,
                                                             reverse=True)
        self._specific_conversion_chains = sorted(self._specific_conversion_chains, key=len, reverse=True)
1077078
def is_object_type(type_):
    

    object_types = _get_types(Types.OBJECT)
    if is_typing_type(type_):
        return type_ in object_types or (
            hasattr(type_, "__origin__") and type_.__origin__ in object_types
        )
    return type_ in object_types
1328935
def _start_tracer(self, origin):
        
        tracer = self._tracer_class(log=self.log)
        tracer.data = self.data
        fn = tracer.start(origin)
        self.tracers.append(tracer)
        return fn
843581
public void registerConvertor(Class src, Class dest, Convertor convertor) {
        repository.registerConvertor(src, dest, convertor);
    }
844711
def _generate_struct_or_union_class_custom_annotations(self):
        
        self.emit('def _process_custom_annotations(')
        with self.indent():
            self.emit('self,')
            self.emit('annotation_type: Type[T],')
            self.emit('field_path: Text,')
            self.emit('processor: Callable[[T, U], U],')
            self.import_tracker._register_typing_import('Type')
            self.import_tracker._register_typing_import('Text')
            self.import_tracker._register_typing_import('Callable')
        self.emit(') -> None: ...')
        self.emit()
294636
def _reregister_types(self):
        """"""
        for _type in self._register_types:
            psycopg2.extensions.register_type(psycopg2.extensions.new_type(*_type))
158700
public static <E> void registerTypeConverter(Class<E> cls, TypeConverter<E> converter) {
        TYPE_CONVERTERS.put(cls, converter);
    }
182009
public ConverterRegistry putCustom(Type type, Class<? extends Converter<?>> converterClass) {
		return putCustom(type, ReflectUtil.newInstance(converterClass));
	}