-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the
property
built-in as a decorator
The use of the `property` built-in as a function does not allow for the same type annotations as using `property` as a deocorator. This change should not affect runtime behaviour and there is test coverage for all properties that were changed to decorators. There are still other places where `property` is used as a function but this is outside of the core parts of RDFLib.
Showing
7 changed files
with
165 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Consistent Test Data | ||
|
||
This directory contains consistent graphs that can be used inside tests, the | ||
graphs in this directory should not change. | ||
|
||
|
||
## File origins | ||
|
||
- `rdfs.ttl`: `http://www.w3.org/2000/01/rdf-schema#` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
@prefix dc: <http://purl.org/dc/elements/1.1/> . | ||
|
||
<http://www.w3.org/2000/01/rdf-schema#> a owl:Ontology ; | ||
dc:title "The RDF Schema vocabulary (RDFS)" . | ||
|
||
rdfs:Resource a rdfs:Class ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "Resource" ; | ||
rdfs:comment "The class resource, everything." . | ||
|
||
rdfs:Class a rdfs:Class ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "Class" ; | ||
rdfs:comment "The class of classes." ; | ||
rdfs:subClassOf rdfs:Resource . | ||
|
||
rdfs:subClassOf a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "subClassOf" ; | ||
rdfs:comment "The subject is a subclass of a class." ; | ||
rdfs:range rdfs:Class ; | ||
rdfs:domain rdfs:Class . | ||
|
||
rdfs:subPropertyOf a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "subPropertyOf" ; | ||
rdfs:comment "The subject is a subproperty of a property." ; | ||
rdfs:range rdf:Property ; | ||
rdfs:domain rdf:Property . | ||
|
||
rdfs:comment a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "comment" ; | ||
rdfs:comment "A description of the subject resource." ; | ||
rdfs:domain rdfs:Resource ; | ||
rdfs:range rdfs:Literal . | ||
|
||
rdfs:label a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "label" ; | ||
rdfs:comment "A human-readable name for the subject." ; | ||
rdfs:domain rdfs:Resource ; | ||
rdfs:range rdfs:Literal . | ||
|
||
rdfs:domain a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "domain" ; | ||
rdfs:comment "A domain of the subject property." ; | ||
rdfs:range rdfs:Class ; | ||
rdfs:domain rdf:Property . | ||
|
||
rdfs:range a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "range" ; | ||
rdfs:comment "A range of the subject property." ; | ||
rdfs:range rdfs:Class ; | ||
rdfs:domain rdf:Property . | ||
|
||
rdfs:seeAlso a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "seeAlso" ; | ||
rdfs:comment "Further information about the subject resource." ; | ||
rdfs:range rdfs:Resource ; | ||
rdfs:domain rdfs:Resource . | ||
|
||
rdfs:isDefinedBy a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:subPropertyOf rdfs:seeAlso ; | ||
rdfs:label "isDefinedBy" ; | ||
rdfs:comment "The defininition of the subject resource." ; | ||
rdfs:range rdfs:Resource ; | ||
rdfs:domain rdfs:Resource . | ||
|
||
rdfs:Literal a rdfs:Class ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "Literal" ; | ||
rdfs:comment "The class of literal values, eg. textual strings and integers." ; | ||
rdfs:subClassOf rdfs:Resource . | ||
|
||
rdfs:Container a rdfs:Class ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "Container" ; | ||
rdfs:subClassOf rdfs:Resource ; | ||
rdfs:comment "The class of RDF containers." . | ||
|
||
rdfs:ContainerMembershipProperty a rdfs:Class ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "ContainerMembershipProperty" ; | ||
rdfs:comment """The class of container membership properties, rdf:_1, rdf:_2, ..., | ||
all of which are sub-properties of 'member'.""" ; | ||
rdfs:subClassOf rdf:Property . | ||
|
||
rdfs:member a rdf:Property ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "member" ; | ||
rdfs:comment "A member of the subject resource." ; | ||
rdfs:domain rdfs:Resource ; | ||
rdfs:range rdfs:Resource . | ||
|
||
rdfs:Datatype a rdfs:Class ; | ||
rdfs:isDefinedBy <http://www.w3.org/2000/01/rdf-schema#> ; | ||
rdfs:label "Datatype" ; | ||
rdfs:comment "The class of RDF datatypes." ; | ||
rdfs:subClassOf rdfs:Class . | ||
|
||
<http://www.w3.org/2000/01/rdf-schema#> rdfs:seeAlso <http://www.w3.org/2000/01/rdf-schema-more> . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
from rdflib import Graph | ||
from rdflib.resource import Resource | ||
from pathlib import Path | ||
from rdflib.namespace import RDFS | ||
import pytest | ||
|
||
TEST_DIR = Path(__file__).parent | ||
|
||
|
||
@pytest.fixture | ||
def rdfs_graph() -> Graph: | ||
return Graph().parse( | ||
TEST_DIR / "consistent_test_data" / "rdfs.ttl", format="turtle" | ||
) | ||
|
||
|
||
def test_properties(rdfs_graph: Graph) -> None: | ||
cres = Resource(rdfs_graph, RDFS.Container) | ||
assert cres.graph is rdfs_graph | ||
assert cres.identifier == RDFS.Container |