Skip to content

datatypes

Utility functions for supporting the XML Schema Datatypes hierarchy

Functions:

Attributes:

XSD_DTs module-attribute

XSD_DTs: Set[URIRef] = set((integer, decimal, float, double, string, boolean, dateTime, nonPositiveInteger, negativeInteger, long, int, short, byte, nonNegativeInteger, unsignedLong, unsignedInt, unsignedShort, unsignedByte, positiveInteger, date))

XSD_DateTime_DTs module-attribute

XSD_DateTime_DTs = set((dateTime, date, time))

XSD_Duration_DTs module-attribute

XSD_Duration_DTs = set((duration, dayTimeDuration, yearMonthDuration))

type_promotion

type_promotion(t1: URIRef, t2: Optional[URIRef]) -> URIRef
Source code in rdflib/plugins/sparql/datatypes.py
def type_promotion(t1: URIRef, t2: Optional[URIRef]) -> URIRef:
    if t2 is None:
        return t1
    t1 = _super_types.get(t1, t1)
    t2 = _super_types.get(t2, t2)
    if t1 == t2:
        return t1  # matching super-types
    try:
        if TYPE_CHECKING:
            # type assert because mypy is confused and thinks t2 can be None
            assert t2 is not None
        return _typePromotionMap[t1][t2]
    except KeyError:
        raise TypeError("Operators cannot combine datatypes %s and %s" % (t1, t2))