Skip to content

Commit

Permalink
Finish adding types to rosidl_parser (#832)
Browse files Browse the repository at this point in the history
* Add types to defintions

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Move Literal import

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Cleaner Literals

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Add py.typed

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* init

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* type complete

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* flake8 fixes

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* add dep to package.xml

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* fix None return bug

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* path recursive

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* fix build error

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* remove no any return

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* cmake mypy

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* resolve constant bug

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Add Branch defintion

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* Moved ParseTree into try except

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* remove try except

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* fix comment

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* use Match and Pattern from typing module

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

* old lark version work arounds

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>

---------

Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
  • Loading branch information
InvincibleRMC authored Nov 22, 2024
1 parent 2a808dc commit 585711e
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 89 deletions.
1 change: 1 addition & 0 deletions rosidl_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ament_python_install_package(${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
find_package(ament_cmake_mypy REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

Expand Down
1 change: 1 addition & 0 deletions rosidl_parser/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<exec_depend>python3-lark-parser</exec_depend>
<exec_depend>rosidl_adapter</exec_depend> <!-- TODO(dirk-thomas) only for backward compatibilty -->

<test_depend>ament_cmake_mypy</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
9 changes: 5 additions & 4 deletions rosidl_parser/rosidl_parser/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Final
from typing import Iterable
from typing import List
from typing import Literal
from typing import Optional
from typing import Set
from typing import Tuple
Expand Down Expand Up @@ -95,7 +96,7 @@
)

if TYPE_CHECKING:
from typing import Literal, TypeAlias
from typing_extensions import TypeAlias
SignedNonexplicitIntegerTypeValues = Literal['short', 'long', 'long long']
UnsignedNonexplicitIntegerTypeValues = Literal['unsigned short', 'unsigned long',
'unsigned long long']
Expand All @@ -108,7 +109,7 @@
BooleanValue = Literal['boolean']
OctetValue = Literal['octet']

SignedExplicitIntegerTypeValues = Literal['int8', 'int16', 'int32' 'int64']
SignedExplicitIntegerTypeValues = Literal['int8', 'int16', 'int32', 'int64']
UnsignedExplicitIntegerTypeValues = Literal['uint8', 'uint16', 'uint32', 'uint64']

ExplicitIntegerTypeValues = Union[SignedExplicitIntegerTypeValues,
Expand Down Expand Up @@ -299,7 +300,7 @@ class BoundedWString(AbstractWString):

__slots__ = ('maximum_size', )

def __init__(self, maximum_size: int) -> None:
def __init__(self, maximum_size: Union[int, str]) -> None:
"""
Create a BoundedWString.
Expand Down Expand Up @@ -803,7 +804,7 @@ class IdlLocator:

__slots__ = ('basepath', 'relative_path')

def __init__(self, basepath: str, relative_path: str) -> None:
def __init__(self, basepath: pathlib.Path, relative_path: pathlib.Path) -> None:
"""
Create an IdlLocator.
Expand Down
Loading

0 comments on commit 585711e

Please sign in to comment.