Skip to content

Commit 201a725

Browse files
committed
upgrade to pyo3 0.28
All uses of #[pyclass] have been annotated with from_py_object or skip_from_py_object.
1 parent 571d9ab commit 201a725

70 files changed

Lines changed: 469 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 38 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ crate-type = ["cdylib"]
1515
autosar-data = {version = "0.21"}
1616
autosar-data-specification = {version = "0.21"}
1717
autosar-data-abstraction = {version = "0.10"}
18-
pyo3 = "0.27"
18+
pyo3 = "0.28"

python/autosar_data/__init__.pyi

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import autosar_data.abstraction
2121

2222
# from ._autosar_data import *
2323
from typing import (
24+
Optional,
2425
final,
2526
Dict,
2627
FrozenSet,
@@ -280,7 +281,7 @@ class AutosarVersion:
280281
A version of the Autosar standard
281282
"""
282283

283-
def __init__(self, verstring: str) -> AutosarVersion: ...
284+
def __init__(self, verstring: str) -> None: ...
284285
def __lt__(self, other: AutosarVersion) -> bool: ...
285286
def __le__(self, other: AutosarVersion) -> bool: ...
286287
def __eq__(self, other: AutosarVersion) -> bool: ...
@@ -309,6 +310,7 @@ class AutosarVersion:
309310
AUTOSAR_00051: AutosarVersion
310311
AUTOSAR_00052: AutosarVersion
311312
AUTOSAR_00053: AutosarVersion
313+
AUTOSAR_00054: AutosarVersion
312314
LATEST: AutosarVersion
313315

314316
@final
@@ -371,24 +373,24 @@ class Element:
371373
comment: str
372374
"""XML comment attached to this element"""
373375
def create_sub_element(
374-
self, element_name: ElementName, position: int = None
376+
self, element_name: ElementName, position: Optional[int] = None
375377
) -> Element:
376378
"""create a sub element under this element with the given ElementName (optionally at a specific position)"""
377379
...
378380

379381
def create_named_sub_element(
380-
self, element_name: ElementName, item_name: str, position: int = None
382+
self, element_name: ElementName, item_name: str, position: Optional[int] = None
381383
) -> Element:
382384
"""create a named sub element under this element with the given ElementName (optionally at a specific position)"""
383385
...
384386

385387
def create_copied_sub_element(
386-
self, other: Element, position: int = None
388+
self, other: Element, position: Optional[int] = None
387389
) -> Element:
388390
"""create a copy of some other element (with all of its children) as a child of this element (optionally at a specific position)"""
389391
...
390392

391-
def move_element_here(self, move_element: Element, position: int = None) -> Element:
393+
def move_element_here(self, move_element: Element, position: Optional[int] = None) -> Element:
392394
"""move an element from somewhere else in this model or from another model to become a child element (optionally at a specific position)"""
393395
...
394396

@@ -644,11 +646,11 @@ class CharacterDataTypeUnsignedInt:
644646
def __repr__(self) -> str: ...
645647
def __str__(self) -> str: ...
646648

647-
def check_file(filename: str):
649+
def check_file(filename: str) -> bool:
648650
"""Check if the file contains arxml data. Returns true if an arxml file header is found and does not parse anything after it."""
649651
...
650652

651-
def check_buffer(input: Union[str, bytes]):
653+
def check_buffer(input: Union[str, bytes]) -> bool:
652654
"""Check if the buffer contains arxml data. Returns true if an arxml file header is found and does not parse anything after it."""
653655
...
654656

src/abstraction/arpackage.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ use pyo3::prelude::*;
3333
//##################################################################
3434

3535
/// An `ArPackage` is an Autosar package, which can contain other packages or elements
36-
#[pyclass(frozen, eq, module = "autosar_data._autosar_data._abstraction")]
36+
#[pyclass(
37+
skip_from_py_object,
38+
frozen,
39+
eq,
40+
module = "autosar_data._autosar_data._abstraction"
41+
)]
3742
#[derive(Clone, PartialEq)]
3843
pub(crate) struct ArPackage(pub(crate) autosar_data_abstraction::ArPackage);
3944

src/abstraction/communication/cluster/can.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use pyo3::prelude::*;
1515
/// A `CanCluster` contains all configuration items associated with a CAN network.
1616
/// The cluster connects multiple ECUs.
1717
#[pyclass(
18+
from_py_object,
1819
frozen,
1920
eq,
2021
module = "autosar_data._autosar_data._abstraction._communication"

src/abstraction/communication/cluster/ethernet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use autosar_data_abstraction::{self, AbstractionElement, IdentifiableAbstraction
99
/// An `EthernetCluster` contains all configuration items associated with an ethernet network.
1010
/// The cluster connects multiple ECUs.
1111
#[pyclass(
12+
from_py_object,
1213
frozen,
1314
eq,
1415
module = "autosar_data._autosar_data._abstraction._communication"

0 commit comments

Comments
 (0)