Skip to content

datatypes

Utility functions for supporting the XML Schema Datatypes hierarchy

Functions:

Attributes:

XSD_DTs module-attribute

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

XSD_DateTime_DTs module-attribute

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

XSD_Duration_DTs module-attribute

XSD_Duration_DTs = set((XSD.duration, XSD.dayTimeDuration, XSD.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))