Python: Annotates immutable classes as frozen

pull/519/head
Tpt 1 year ago committed by Thomas Tanon
parent 5d253c6afb
commit a7758484a5
  1. 14
      python/src/model.rs
  2. 2
      python/src/sparql.rs

@ -20,7 +20,7 @@ use std::vec::IntoIter;
///
/// >>> str(NamedNode('http://example.com'))
/// '<http://example.com>'
#[pyclass(name = "NamedNode", module = "pyoxigraph")]
#[pyclass(frozen, name = "NamedNode", module = "pyoxigraph")]
#[pyo3(text_signature = "(value)")]
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)]
pub struct PyNamedNode {
@ -144,7 +144,7 @@ impl PyNamedNode {
///
/// >>> str(BlankNode('ex'))
/// '_:ex'
#[pyclass(name = "BlankNode", module = "pyoxigraph")]
#[pyclass(frozen, name = "BlankNode", module = "pyoxigraph")]
#[pyo3(text_signature = "(value = None)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyBlankNode {
@ -280,7 +280,7 @@ impl PyBlankNode {
/// '"example"@en'
/// >>> str(Literal('11', datatype=NamedNode('http://www.w3.org/2001/XMLSchema#integer')))
/// '"11"^^<http://www.w3.org/2001/XMLSchema#integer>'
#[pyclass(name = "Literal", module = "pyoxigraph")]
#[pyclass(frozen, name = "Literal", module = "pyoxigraph")]
#[pyo3(text_signature = "(value, *, datatype = None, language = None)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyLiteral {
@ -427,7 +427,7 @@ impl PyLiteral {
}
/// The RDF `default graph name <https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph>`_.
#[pyclass(name = "DefaultGraph", module = "pyoxigraph")]
#[pyclass(frozen, name = "DefaultGraph", module = "pyoxigraph")]
#[pyo3(text_signature = "()")]
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub struct PyDefaultGraph {}
@ -625,7 +625,7 @@ impl IntoPy<PyObject> for PyTerm {
/// A triple could also be easily destructed into its components:
///
/// >>> (s, p, o) = Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'))
#[pyclass(name = "Triple", module = "pyoxigraph")]
#[pyclass(frozen, name = "Triple", module = "pyoxigraph")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
#[pyo3(text_signature = "(subject, predicate, object)")]
pub struct PyTriple {
@ -824,7 +824,7 @@ impl IntoPy<PyObject> for PyGraphName {
/// A quad could also be easily destructed into its components:
///
/// >>> (s, p, o, g) = Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))
#[pyclass(name = "Quad", module = "pyoxigraph")]
#[pyclass(frozen, name = "Quad", module = "pyoxigraph")]
#[pyo3(text_signature = "(subject, predicate, object, graph_name = None)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyQuad {
@ -1012,7 +1012,7 @@ impl PyQuad {
///
/// >>> str(Variable('foo'))
/// '?foo'
#[pyclass(name = "Variable", module = "pyoxigraph")]
#[pyclass(frozen, name = "Variable", module = "pyoxigraph")]
#[pyo3(text_signature = "(value)")]
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct PyVariable {

@ -88,7 +88,7 @@ pub fn query_results_to_python(py: Python<'_>, results: QueryResults) -> PyObjec
/// >>> s, p, o = solution
/// >>> s
/// <NamedNode value=http://example.com>
#[pyclass(unsendable, name = "QuerySolution", module = "pyoxigraph")]
#[pyclass(frozen, unsendable, name = "QuerySolution", module = "pyoxigraph")]
pub struct PyQuerySolution {
inner: QuerySolution,
}

Loading…
Cancel
Save