Skip to content

Commit 846ffbe

Browse files
chore: fix pydantic warnings
1 parent 6c57202 commit 846ffbe

File tree

6 files changed

+18
-21
lines changed

6 files changed

+18
-21
lines changed

kmm/functional_base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
from pydantic import BaseModel, Extra
1+
from pydantic import BaseModel, ConfigDict
22

33

44
class FunctionalBase(BaseModel):
5-
class Config:
6-
allow_mutation = False
7-
extra = Extra.forbid
5+
model_config = ConfigDict(frozen=True, extra="forbid")
86

97
def map(self, fn, *args, **kwargs):
108
return fn(self, *args, **kwargs)
119

1210
def replace(self, **kwargs):
13-
new_dict = self.dict()
11+
new_dict = self.model_dump()
1412
new_dict.update(**kwargs)
1513
return type(self)(**new_dict)

kmm/header/header.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22
from xml.etree import ElementTree
33

4-
from pydantic import validate_arguments
4+
from pydantic import validate_call
55

66
import kmm
77

@@ -12,7 +12,7 @@ class Header(kmm.FunctionalBase):
1212
sync: int
1313

1414
@staticmethod
15-
@validate_arguments
15+
@validate_call
1616
def from_path(path: Path, raise_on_malformed_data: bool = True):
1717
"""
1818
Loads header data from .hdr file.

kmm/positions/positions.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22

33
import pandas as pd
4-
from pydantic import validate_arguments
4+
from pydantic import ConfigDict, validate_call
55

66
import kmm
77
from kmm.header.header import Header
@@ -10,11 +10,10 @@
1010
class Positions(kmm.FunctionalBase):
1111
dataframe: pd.DataFrame
1212

13-
class Config:
14-
arbitrary_types_allowed = True
13+
model_config = ConfigDict(arbitrary_types_allowed=True)
1514

1615
@staticmethod
17-
@validate_arguments
16+
@validate_call
1817
def from_path(
1918
path: Path,
2019
raise_on_malformed_data: bool = True,
@@ -37,7 +36,7 @@ def from_path(
3736
return Positions(dataframe=dataframe)
3837

3938
@staticmethod
40-
@validate_arguments
39+
@validate_call
4140
def read_sync_adjust(
4241
kmm_path: Path,
4342
header_path: Path,
@@ -60,7 +59,7 @@ def read_sync_adjust(
6059
.geodetic()
6160
)
6261

63-
@validate_arguments
62+
@validate_call
6463
def sync_frame_index(
6564
self,
6665
header: Header,

kmm/positions/read_kmm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import numpy as np
55
import pandas as pd
6-
from pydantic import validate_arguments
6+
from pydantic import validate_call
77

88

9-
@validate_arguments
9+
@validate_call
1010
def read_kmm(path: Path, replace_commas: bool = True):
1111
try:
1212
if replace_commas:

kmm/positions/read_kmm2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66
import pandas as pd
7-
from pydantic import validate_arguments
7+
from pydantic import validate_call
88

99
pattern = re.compile(r".+\[.+\]")
1010
pattern2 = re.compile(r"CMAST")
@@ -46,7 +46,7 @@
4646
)
4747

4848

49-
@validate_arguments
49+
@validate_call
5050
def read_kmm2(
5151
path: Path, raise_on_malformed_data: bool = True, replace_commas: bool = True
5252
):
@@ -80,9 +80,9 @@ def read_kmm2(
8080
low_memory=False,
8181
)
8282
n_columns = len(pd.read_csv(file_obj, **parser_kwargs).columns)
83-
83+
8484
# Reset file pointer to beginning for StringIO objects
85-
if hasattr(file_obj, 'seek'):
85+
if hasattr(file_obj, "seek"):
8686
file_obj.seek(0)
8787

8888
if n_columns > len(expected_columns):

kmm/positions/sync_frame_index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import numpy as np
2-
from pydantic import validate_arguments
2+
from pydantic import validate_call
33

44
from kmm import CarDirection, PositionAdjustment
55
from kmm.header.header import Header
66
from kmm.positions.positions import Positions
77

88

9-
@validate_arguments(config=dict(arbitrary_types_allowed=True))
9+
@validate_call(config=dict(arbitrary_types_allowed=True))
1010
def sync_frame_index(
1111
positions: Positions,
1212
header: Header,

0 commit comments

Comments
 (0)