def canonicalize(self, type=None, childType=None):
        type = type
        childType = childType
        # Push type into the first segment, as long as it's possible.
        if type is not None:
            if self.segments[0].type is None:
                self.segments[0] = self.segments[0]._replace(type=type)
            elif self.segments[0] == type:
                pass
            else:
                die("Tried to force-canonicalize '{0}' as type '{1}', but it's already '{2}'.", str(self), type, self.segments[0].type)
                self.valid = False
                return self

        def guessType(value, type, prevType, nextValue):
            if type is not None:
                return type
            if prevType is None:
                if config.typeRe['at-rule'].match(value):
                    return "at-rule"
                if config.typeRe['selector'].match(value):
                    return "selector"
                if config.typeRe['type'].match(value):
                    return "type"
                return None
            else:
                if prevType == "descriptor" and config.typeRe['at-rule'].match(value):
                    return "at-rule"
                if prevType == "value":
                    if config.typeRe['at-rule'].match(value):
                        return "at-rule"
                    if config.typeRe['type'].match(value):
                        return "type"
                    if config.typeRe['function'].match(value):
                        return "function"
                    if config.typeRe['selector'].match(value):
                        return "selector"
                    if config.typeRe['descriptor'].match(value) and config.typeRe['at-rule'].match(nextValue):
                        return "descriptor"
                    if config.typeRe['property'].match(value):
                        return "property"
                if prevType in ("method", "constructor", "attribute", "const", "event", "stringifier", "serializer", "iterator") and config.typeRe['interface'].match(value):
                    return "interface"
                if prevType == "argument" and config.typeRe['method'].match(value):
                    return "method"
                if prevType == "dict-member" and config.typeRe['dictionary'].match(value):
                    return "dictionary"
                if prevType == "except-field" and config.typeRe['exception'].match(value):
                    return "exception"
                return None
        for i, segment in enumerate(self.segments):
            prevType = childType if i == 0 else self.segments[i-1].type
            nextValue = '' if i+1 == len(self.segments) else self.segments[i+1].value
            self.segments[i] = segment._replace(type=guessType(*segment, prevType=prevType, nextValue=nextValue))
        return self
If an error is present, then log it.
dataset/ETHPy150Open tabatkins/bikeshed/bikeshed/globalnames.py/GlobalName.canonicalize--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/bulkloader.py/_ThreadBase.CheckError