Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static typing for Message, Services, and Actions #206

Open
wants to merge 55 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f81e023
explicit export and py.typed
InvincibleRMC Mar 1, 2024
2f99351
Fix line lengths
InvincibleRMC Mar 1, 2024
05761d8
Fix hanging indent
InvincibleRMC Mar 1, 2024
9807b07
Improve typing
InvincibleRMC Mar 15, 2024
288ba5d
Fix subscription error
InvincibleRMC Mar 15, 2024
9aad27a
Tests complete
InvincibleRMC Mar 15, 2024
2822852
Fewer flake8
InvincibleRMC Mar 15, 2024
118b9ef
Fix typing import error
InvincibleRMC Mar 15, 2024
af91451
Update _msg.py.em
InvincibleRMC Mar 15, 2024
153a6d7
Constructor typing refactor
InvincibleRMC Mar 17, 2024
6a147a7
Update _msg.py.em
InvincibleRMC Mar 17, 2024
946381a
remove structure_needs_at_least_one_member
InvincibleRMC Mar 18, 2024
956fe0a
Add actual numpy type annotations
InvincibleRMC Mar 18, 2024
ae98901
Add None
InvincibleRMC Mar 18, 2024
8d06b8c
Add types to __prepare__ args
InvincibleRMC Mar 18, 2024
ad14966
Default type annotations
InvincibleRMC Mar 19, 2024
48def6b
Constant type annotations
InvincibleRMC Mar 19, 2024
8458b38
Type constants
InvincibleRMC Mar 19, 2024
9f80bcc
SLOT_TYPES type
InvincibleRMC Mar 19, 2024
4b2f72c
small refactor
InvincibleRMC Mar 19, 2024
a412da2
Add Protocol
InvincibleRMC Mar 19, 2024
86d8a97
Blank lines for flake8
InvincibleRMC Mar 19, 2024
5d839f4
Remove Literal for better 3.6 support
InvincibleRMC Mar 19, 2024
1aef88a
Better return types
InvincibleRMC Mar 19, 2024
468c8f5
Move TYPE_CHECKING import
InvincibleRMC Mar 19, 2024
432a9dc
or syntax
InvincibleRMC Mar 19, 2024
5397591
Merge branch 'rolling' into message-types
InvincibleRMC Sep 4, 2024
af7463a
Literal Clean up
InvincibleRMC Sep 4, 2024
bb4ca22
remove forward reference
InvincibleRMC Sep 4, 2024
b0667d2
remove string wrapper
InvincibleRMC Sep 4, 2024
3fca5b1
replace quotes with '
InvincibleRMC Sep 4, 2024
4a8fdf3
add mypy test
InvincibleRMC Sep 4, 2024
68629fa
add mypy test
InvincibleRMC Sep 4, 2024
f1d38a7
resolve truthy assert
InvincibleRMC Sep 4, 2024
a5b8d41
move Literal import
InvincibleRMC Sep 4, 2024
1886955
update string literals
InvincibleRMC Sep 5, 2024
d3acf35
fix Literal float
InvincibleRMC Sep 5, 2024
9d10ab5
Add some types into rosidl_generator_py
InvincibleRMC Sep 5, 2024
33d126a
type_support import
InvincibleRMC Sep 5, 2024
829c25b
remove file
InvincibleRMC Sep 5, 2024
9b95b02
fix byte litearls
InvincibleRMC Sep 5, 2024
010db3f
remove ovveride
InvincibleRMC Sep 5, 2024
ffc1b37
fix __prepare__
InvincibleRMC Sep 5, 2024
5752835
fix metacls
InvincibleRMC Sep 5, 2024
ad8fd40
remove ByteString from isinstance
InvincibleRMC Sep 5, 2024
e7a2ed6
import error
InvincibleRMC Sep 5, 2024
f1966c7
switch typing improt
InvincibleRMC Sep 5, 2024
95c8e52
move Literal import
InvincibleRMC Sep 5, 2024
375cc73
match getter and setter
InvincibleRMC Sep 5, 2024
576fe24
fix numpy types
InvincibleRMC Sep 5, 2024
381d1e1
resolve all()
InvincibleRMC Sep 5, 2024
41cc561
fix mypy error
InvincibleRMC Sep 5, 2024
6e357c3
type ignore around mypy#3004
InvincibleRMC Sep 6, 2024
dd5c3e9
revert specifc getter type
InvincibleRMC Sep 7, 2024
b6bc52c
Use Any to avoid mypy#3004
InvincibleRMC Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,10 @@ if(BUILD_TESTING AND rosidl_generate_interfaces_ADD_LINTER_TESTS)
# a value of zero tells uncrustify to ignore line length
MAX_LINE_LENGTH 0
"${_output_path}")

find_package(ament_cmake_mypy REQUIRED)
ament_mypy(
TESTNAME "mypy_rosidl_generate_py"
"${_output_path}")
endif()
endif()
1 change: 1 addition & 0 deletions rosidl_generator_py/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<exec_depend>ament_cmake_cppcheck</exec_depend>
<exec_depend>ament_cmake_cpplint</exec_depend>
<exec_depend>ament_cmake_flake8</exec_depend>
<exec_depend>ament_cmake_mypy</exec_depend>
<exec_depend>ament_cmake_pep257</exec_depend>
<exec_depend>ament_cmake_uncrustify</exec_depend>

Expand Down
Empty file added rosidl_generator_py/py.typed
Empty file.
4 changes: 2 additions & 2 deletions rosidl_generator_py/resource/_action.py.em
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Metaclass_@(action.namespaced_type.name)(type):
_TYPE_SUPPORT = None

@@classmethod
def __import_type_support__(cls):
def __import_type_support__(cls) -> None:
try:
from rosidl_generator_py import import_type_support
module = import_type_support('@(package_name)')
Expand Down Expand Up @@ -92,5 +92,5 @@ class @(action.namespaced_type.name)(metaclass=Metaclass_@(action.namespaced_typ
# The generic message for get the status of a goal.
from action_msgs.msg._goal_status_array import GoalStatusArray as GoalStatusMessage

def __init__(self):
def __init__(self) -> None:
raise NotImplementedError('Action classes can not be instantiated')
2 changes: 2 additions & 0 deletions rosidl_generator_py/resource/_idl.py.em
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# This is being done at the module level and not on the instance level to avoid looking
# for the same variable multiple times on each instance. This variable is not supposed to
# change during runtime so it makes sense to only look for it once.
from collections.abc import MutableMapping
from os import getenv
from typing import Any, ClassVar, Dict, Optional, Tuple, Type, TYPE_CHECKING, TypedDict

ros_python_check_fields = getenv('ROS_PYTHON_CHECK_FIELDS', default='')
@
Expand Down
Loading