From 6cf54037a057d5bfe6d54ff96dd718fb389eb4f4 Mon Sep 17 00:00:00 2001 From: Lukas Plank Date: Sat, 19 Oct 2024 14:27:23 +0200 Subject: [PATCH] docs(readme): update Python code examples to ConfigDict Also include imports in the example code. --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 74c8b7e..334f42a 100644 --- a/README.md +++ b/README.md @@ -44,24 +44,27 @@ retrieves the result set: The result set can be mapped to a nested Pydantic model like so: ```python +from typing import Annotated + +from fastapi import FastAPI +from pydantic import BaseModel, ConfigDict +from rdfproxy import Page, SPARQLBinding, SPARQLModelAdapter + + class Work(BaseModel): - class Config: - group_by = "work_name" + model_config = ConfigDict(group_by="work_name") name: Annotated[str, SPARQLBinding("work_name")] viafs: Annotated[list[str], SPARQLBinding("viaf")] - class Author(BaseModel): - class Config: - group_by = "nameLabel" + model_config = ConfigDict(group_by="nameLabel") gnd: str surname: Annotated[str, SPARQLBinding("nameLabel")] works: list[Work] education: Annotated[list[str], SPARQLBinding("educated_atLabel")] - adapter = SPARQLModelAdapter( target="https://query.wikidata.org/bigdata/namespace/wdq/sparql", query=query,