Skip to content

Commit c06d6fc

Browse files
authored
Update pydantic to 2.11+, address DeprecationWarnings (#487)
### What kind of change does this PR introduce? * Raises the minimum version of `pydantic` to v2.11 * Addresses ~6500 `DeprecationWarning`s emitted from `pydantic` ### Does this PR introduce a breaking change? Not really. Newer `pydantic` has been added as a dependency.
2 parents 2514677 + 138978d commit c06d6fc

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ New features
1212
Internal changes
1313
^^^^^^^^^^^^^^^^
1414
* `pydap` has been pinned below v3.5.5 temporarily until `xarray` offers support for it. (PR #486).
15+
* More than 7500 DeprecationWarnings emitted during the testing suite have been addressed. Minimum supported `pydantic` has been raised to v2.11. (PR #487).
1516

1617
v0.18.0 (2025-04-03)
1718
--------------------

environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies:
2323
- pandas >=2.2.0
2424
- pint >=0.24.4
2525
- platformdirs >=4.3.6
26-
- pydantic >=2.0
26+
- pydantic >=2.11
2727
- pydap >=3.4.0,<3.5.5 # pydap 3.5.5 is not currently supported by `xarray` (v2025.3.1)
2828
- pymetalink >=6.5.2
2929
- pymbolic >=2024.2

environment-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies:
3131
- netCDF4 >=1.7.2
3232
- numpy >=1.24.0
3333
- notebook
34-
- pydantic >=2.0
34+
- pydantic >=2.11
3535
- pymetalink >=6.5.2
3636
- s3fs
3737
- salib

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies = [
4949
"pandas >=2.2.0",
5050
"pint >=0.24.4",
5151
"platformdirs >=4.3.6",
52-
"pydantic >=2.0",
52+
"pydantic >=2.11",
5353
"pydap >=3.4.0,<3.5.5", # pydap 3.5.5 is not currently supported by `xarray` (v2025.3.1)
5454
"pymbolic >=2024.2",
5555
"scipy >=1.11.0",

src/ravenpy/config/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ def __subcommands__(self) -> tuple[dict[str, str], list]:
144144
"""Return dictionary of class attributes that are Raven models."""
145145
cmds = {}
146146
recs = []
147-
for key, field in self.model_fields.items():
147+
cls = self.__class__
148+
for key, field in cls.model_fields.items():
148149
obj = self.__dict__[key]
149150
if obj is not None:
150151
if issubclass(obj.__class__, _Record):
@@ -225,8 +226,9 @@ class LineCommand(FlatCommand):
225226
"""
226227

227228
def to_rv(self):
228-
out = [f":{self.__class__.__name__:<20}"]
229-
for field in self.model_fields.keys():
229+
cls = self.__class__
230+
out = [f":{cls.__name__:<20}"]
231+
for field in cls.model_fields.keys():
230232
out.append(str(getattr(self, field))) # noqa: PERF401
231233

232234
return " ".join(out) + "\n"

tests/test_rvs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Test(RV):
1818
a: bool = optfield(alias="a")
1919

2020
t = Test()
21-
assert not t.model_fields["a"].is_required()
21+
assert not t.__class__.model_fields["a"].is_required()
2222

2323

2424
def test_rvi_datetime():

0 commit comments

Comments
 (0)