Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated pydantic examples such that they work for pydantic > 2.10.0 #1054

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 25 additions & 31 deletions examples/datamodel_as_rdf/dataresource_pydantic2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions requirements_full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pymongo>=4.4.0,<5
#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

Expand Down
Loading