Skip to content

"Official stance is Subject can be a Literal" #3172

@multimeric

Description

@multimeric

Clearly this dilemma is known to the maintainers, but I don't think there is any issue about it yet:

rdflib/rdflib/graph.py

Lines 324 to 328 in 53405b7

# RDFLib official stance is Subject can be a Literal
# If this ever changes, this part will be one of the first lines to modify.
_SubjectType: te.TypeAlias = Union[IdentifiedNode, Literal, Variable]
_PredicateType: te.TypeAlias = Union[IdentifiedNode, Variable]
_ObjectType: te.TypeAlias = Union[IdentifiedNode, Literal, Variable]

This is fairly frustrating to work with, as I need to do lots of subclass checking whenever I work with subject triples.

Here is the relevant part of the RDF spec:

An RDF triple consists of three components:
• the subject, which is an IRI or a blank node
• the predicate, which is an IRI
• the object, which is an IRI, a literal or a blank node

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions