diff --git a/examples/datamodel_as_rdf/dataresource_pydantic2.py b/examples/datamodel_as_rdf/dataresource_pydantic2.py index 0d70a0d95..2300f344b 100644 --- a/examples/datamodel_as_rdf/dataresource_pydantic2.py +++ b/examples/datamodel_as_rdf/dataresource_pydantic2.py @@ -16,6 +16,8 @@ print("This example requires pydantic v2") raise SystemExit(44) +HostlessAnyUrl = Annotated[AnyUrl, UrlConstraints(host_required=False)] + class ResourceConfig(BaseModel): """Resource Strategy Data Configuration. @@ -25,21 +27,17 @@ class ResourceConfig(BaseModel): `accessUrl`/`accessService` MUST be specified. """ - downloadUrl: Annotated[ - Optional[AnyUrl], - UrlConstraints(host_required=False), - Field( - None, - description=( - """Definition: The URL of the downloadable file in a given - format. E.g. CSV " "file or RDF file. + downloadUrl: Optional[HostlessAnyUrl] = Field( + None, + description=( + """Definition: The URL of the downloadable file in a given + format. E.g. CSV " "file or RDF file. - Usage: `downloadURL` *SHOULD* be used for the URL at which - this distribution is available directly, typically through a - HTTPS GET request or SFTP.""" - ), + Usage: `downloadURL` *SHOULD* be used for the URL at which + this distribution is available directly, typically through a + HTTPS GET request or SFTP.""" ), - ] + ) mediaType: Annotated[ Optional[str], Field( @@ -55,25 +53,21 @@ class ResourceConfig(BaseModel): ), ), ] - accessUrl: Annotated[ - Optional[AnyUrl], - UrlConstraints(host_required=False), - Field( - None, - description=( - """A URL of the resource that gives access to a distribution of - the dataset. E.g. landing page, feed, SPARQL endpoint. - - Usage: `accessURL` *SHOULD* be used for the URL of a - service or location that can provide access to this - distribution, typically through a Web form, query or API - call. - - `downloadURL` is preferred for direct links to downloadable - resources.""" - ), + accessUrl: Optional[HostlessAnyUrl] = Field( + None, + description=( + """A URL of the resource that gives access to a distribution of + the dataset. E.g. landing page, feed, SPARQL endpoint. + + Usage: `accessURL` *SHOULD* be used for the URL of a + service or location that can provide access to this + distribution, typically through a Web form, query or API + call. + + `downloadURL` is preferred for direct links to downloadable + resources.""" ), - ] + ) accessService: Annotated[ Optional[str], Field( diff --git a/requirements_full.txt b/requirements_full.txt index ef6e46d98..ae0d86176 100644 --- a/requirements_full.txt +++ b/requirements_full.txt @@ -22,8 +22,8 @@ urllib3>=1.0.0,<2 #psycopg2>=2,<3 # Utilities -# Bug in pydantic 2.10.1, see https://github.com/pydantic/pydantic/issues/9898 -pydantic>=1.10.0,!=2.10.0,!=2.10.1,<2.10.2 +# Bug in pydantic 2.10.0, see https://github.com/pydantic/pydantic/issues/9898 +pydantic>=1.10.0,!=2.10.0,<2.10.4 typing_extensions>=4.1,<5; python_version<'3.9' fortran-language-server>=1.12.0,<1.13