Skip to content

Commit efd4dc3

Browse files
authored
Merge pull request #388 from pbs-data-solutions/signatures
Add pyo3 signatures
2 parents 76d1f33 + ea01b88 commit efd4dc3

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

prelude_parser/_prelude_parser.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ from prelude_parser._prelude_parser import ( # type: ignore[attr-defined]
1010
from prelude_parser.types import FlatFormInfo
1111

1212
def _parse_flat_file_to_dict(
13-
xml_file: str | Path, short_names: bool
13+
xml_file: str | Path, *, short_names: bool = False
1414
) -> dict[str, FlatFormInfo]: ...
1515
def _parse_flat_file_to_pandas_dict(
16-
xml_file: str | Path, short_names: bool
16+
xml_file: str | Path, *, short_names: bool = False
1717
) -> dict[str, FlatFormInfo]: ...
1818
def parse_site_native_file(xml_file: str | Path) -> SiteNative: ...
1919
def parse_site_native_string(xml_str: str) -> SiteNative: ...

prelude_parser/pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ def to_dataframe(xml_file: str | Path, *, short_names: bool = False) -> pd.DataF
3838
>>> from prelude_parser.pandas import to_dataframe
3939
>>> df = to_dataframe("physical_examination.xml")
4040
"""
41-
data = _parse_flat_file_to_pandas_dict(xml_file, short_names)
41+
data = _parse_flat_file_to_pandas_dict(xml_file, short_names=short_names)
4242
return pd.DataFrame.from_dict(data)

prelude_parser/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def parse_to_dict(xml_file: str | Path, *, short_names: bool = False) -> dict[st
3030
>>> from prelude_parser import parse_to_dict
3131
>>> data = parse_to_dict("physical_examination.xml")
3232
"""
33-
return _parse_flat_file_to_dict(xml_file, short_names)
33+
return _parse_flat_file_to_dict(xml_file, short_names=short_names)
3434

3535

3636
def parse_to_classes(xml_file: str | Path, short_names: bool = False) -> list[Any]:

prelude_parser/polars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ def to_dataframe(xml_file: str | Path, *, short_names: bool = False) -> pl.DataF
2929
>>> from prelude_parser.polars import to_dataframe
3030
>>> df = to_dataframe("physical_examination.xml")
3131
"""
32-
data = _parse_flat_file_to_pandas_dict(xml_file, short_names)
32+
data = _parse_flat_file_to_pandas_dict(xml_file, short_names=short_names)
3333
return pl.from_dict(data)

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ fn parse_xml_pandas<'py>(
213213
}
214214

215215
#[pyfunction]
216+
#[pyo3(signature = (xml_file, *, short_names=false))]
216217
fn _parse_flat_file_to_dict(
217218
py: Python,
218219
xml_file: PathBuf,
@@ -225,6 +226,7 @@ fn _parse_flat_file_to_dict(
225226
}
226227

227228
#[pyfunction]
229+
#[pyo3(signature = (xml_file, *, short_names=false))]
228230
fn _parse_flat_file_to_pandas_dict(
229231
py: Python,
230232
xml_file: PathBuf,
@@ -237,6 +239,7 @@ fn _parse_flat_file_to_pandas_dict(
237239
}
238240

239241
#[pyfunction]
242+
#[pyo3(signature = (xml_file))]
240243
fn parse_site_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SiteNative> {
241244
match parse_site_native_file_rs(&xml_file) {
242245
Ok(native) => Ok(native),
@@ -248,6 +251,7 @@ fn parse_site_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SiteNative
248251
}
249252

250253
#[pyfunction]
254+
#[pyo3(signature = (xml_str))]
251255
fn parse_site_native_string(_py: Python, xml_str: &str) -> PyResult<SiteNative> {
252256
match parse_site_native_string_rs(xml_str) {
253257
Ok(native) => Ok(native),
@@ -256,6 +260,7 @@ fn parse_site_native_string(_py: Python, xml_str: &str) -> PyResult<SiteNative>
256260
}
257261

258262
#[pyfunction]
263+
#[pyo3(signature = (xml_file))]
259264
fn parse_subject_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SubjectNative> {
260265
match parse_subject_native_file_rs(&xml_file) {
261266
Ok(native) => Ok(native),
@@ -267,6 +272,7 @@ fn parse_subject_native_file(_py: Python, xml_file: PathBuf) -> PyResult<Subject
267272
}
268273

269274
#[pyfunction]
275+
#[pyo3(signature = (xml_str))]
270276
fn parse_subject_native_string(_py: Python, xml_str: &str) -> PyResult<SubjectNative> {
271277
match parse_subject_native_string_rs(xml_str) {
272278
Ok(native) => Ok(native),
@@ -275,6 +281,7 @@ fn parse_subject_native_string(_py: Python, xml_str: &str) -> PyResult<SubjectNa
275281
}
276282

277283
#[pyfunction]
284+
#[pyo3(signature = (xml_file))]
278285
fn parse_user_native_file(_py: Python, xml_file: PathBuf) -> PyResult<UserNative> {
279286
match parse_user_native_file_rs(&xml_file) {
280287
Ok(native) => Ok(native),
@@ -286,6 +293,7 @@ fn parse_user_native_file(_py: Python, xml_file: PathBuf) -> PyResult<UserNative
286293
}
287294

288295
#[pyfunction]
296+
#[pyo3(signature = (xml_str))]
289297
fn parse_user_native_string(_py: Python, xml_str: &str) -> PyResult<UserNative> {
290298
match parse_user_native_string_rs(xml_str) {
291299
Ok(native) => Ok(native),

0 commit comments

Comments
 (0)