Skip to content

Commit

Permalink
Revert "monkey patch pydantic_core.Url for str concatentation"
Browse files Browse the repository at this point in the history
This reverts commit 6bd788b.
  • Loading branch information
sblack-usu committed Mar 4, 2024
1 parent 6bd788b commit f9fc223
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 25 deletions.
16 changes: 0 additions & 16 deletions hsmodels/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
from pydantic_core import Url


def __add__(self, other):
return str(self) + other


def __radd__(self, other):
return other + str(self)


# monkey patch string concatentation until pydantic implements Url as an extension of str again
# https://github.com/pydantic/pydantic-core/pull/1126

Url.__add__ = __add__
Url.__radd__ = __radd__
2 changes: 1 addition & 1 deletion hsmodels/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from enum import Enum

from pydantic import BaseModel
from pydantic_core import Url
from rdflib import Graph, Literal, URIRef

from hsmodels import Url
from hsmodels.namespaces import DC, HSTERMS, ORE, RDF, RDFS1
from hsmodels.schemas.aggregations import (
FileSetMetadata,
Expand Down
3 changes: 2 additions & 1 deletion hsmodels/schemas/rdf/validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from hsmodels import Url
from pydantic_core import Url

from hsmodels.schemas.enums import CoverageType, DateType
from hsmodels.schemas.languages_iso import languages

Expand Down
2 changes: 1 addition & 1 deletion hsmodels/schemas/root_validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic_core import Url
from rdflib import URIRef

from hsmodels import Url
from hsmodels.schemas.enums import CoverageType, DateType, ModelProgramFileType, RelationType, UserIdentifierType
from hsmodels.utils import to_coverage_dict

Expand Down
6 changes: 0 additions & 6 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,3 @@ def test_resource_metadata(res_md):
res_md.publisher.name == "Consortium of Universities for the Advancement of Hydrologic Science, Inc. (CUAHSI)"
)
assert str(res_md.publisher.url) == "https://www.cuahsi.org/"


def test_resource_metadata_url_str_concat(res_md):
assert (
"concat test " + res_md.url == "concat test http://www.hydroshare.org/resource/84805fd615a04d63b4eada65644a1e20"
)

0 comments on commit f9fc223

Please sign in to comment.