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

Add types to duration.py #1233

Merged
merged 9 commits into from
Mar 8, 2024
Merged

Add types to duration.py #1233

merged 9 commits into from
Mar 8, 2024

Conversation

InvincibleRMC
Copy link
Contributor

Adds types to duration.py. Also adds an RCLDuration Type/Object Alias so type inference can be on the _duration_handle.

@InvincibleRMC
Copy link
Contributor Author

The problem with that solution is without making some custom type alias mypy, and pylance have to treat _rclpy.rcl_duration_t as type Any which weakens the type inference. For example since the _duration_handle is type Any it cannot reason about the type of the nanoseconds field.

rclpy/rclpy/duration.py:44: error: Returning Any from function declared to return "int" [no-any-return]

@property
    def nanoseconds(self) -> int:
        return self._duration_handle.nanoseconds

InvincibleRMC and others added 6 commits February 29, 2024 19:50
* add types to logging_service

Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
@fujitatomoya
Copy link
Collaborator

@InvincibleRMC thanks for working on this. the reason i do not start CI is to wait for 2nd review. once we have 2nd approval, i will start the CI. (So are other PRs)

@InvincibleRMC
Copy link
Contributor Author

No problem. Thanks so much for the prompt reviews.

Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
@fujitatomoya
Copy link
Collaborator

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@InvincibleRMC InvincibleRMC mentioned this pull request Mar 4, 2024
@clalancette clalancette merged commit ff00de1 into ros2:rolling Mar 8, 2024
3 checks passed
@InvincibleRMC InvincibleRMC deleted the duration branch March 9, 2024 23:22
InvincibleRMC added a commit to InvincibleRMC/rclpy that referenced this pull request Mar 24, 2024
* Add types to logging_service.py (ros2#1227)

* add types to logging_service

* Add types to duration.py

* Add newlines for class definintions

* update type alias name

* Update to use Protocols

Signed-off-by: Michael Carlstrom <[email protected]>
sloretz added a commit that referenced this pull request May 3, 2024
* First draft of generics

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix Generic

Signed-off-by: Michael Carlstrom <[email protected]>

* Add legacy

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix import order

Signed-off-by: Michael Carlstrom <[email protected]>

* fix import order

Signed-off-by: Michael Carlstrom <[email protected]>

* Add Docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

* Add Docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

* Add generics support to Node

Signed-off-by: Michael Carlstrom <[email protected]>

* Update type_support.py

Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to expand_topic_name (#1238)

Signed-off-by: Michael Carlstrom <[email protected]>

* Creates Enum wrapper for ClockType and ClockChange (#1235)

* Testing out Enum wrapper for ClockType

* convert to rcl_clock_type_t

* Update create_time_point

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types (#1231)

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to exceptions.py (#1241)

* Add types to exception

* Add type checking guard

* Fix NotInitializedException

* Add missing defualt

Signed-off-by: Michael Carlstrom <[email protected]>

* added python3-yaml (#1242)

Signed-off-by: SnIcK <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to duration.py (#1233)

* Add types to logging_service.py (#1227)

* add types to logging_service

* Add types to duration.py

* Add newlines for class definintions

* update type alias name

* Update to use Protocols

Signed-off-by: Michael Carlstrom <[email protected]>

* Add Static Typing to Validate files (#1230)

* Add types to validate files

Signed-off-by: Michael Carlstrom <[email protected]>

* remove type annotations from docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

* removed other type annotated docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to TypeHash and moved away from __slots__ usage (#1232)

* Add types to TypeHash and moved away from __slots__ usage

Signed-off-by: Michael Carlstrom <[email protected]>

* remove docstring types

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>

* Time.py Types (#1237)

* Start typing time.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Testing out Enum wrapper for ClockType

Signed-off-by: Michael Carlstrom <[email protected]>

* convert to rcl_clock_type_t

Signed-off-by: Michael Carlstrom <[email protected]>

* Undo Change to time_point.cpp

Signed-off-by: Michael Carlstrom <[email protected]>

* Update create_time_point

Signed-off-by: Michael Carlstrom <[email protected]>

* Lint fixes

Signed-off-by: Michael Carlstrom <[email protected]>

* Add debug message

Signed-off-by: Michael Carlstrom <[email protected]>

* Remove test file

Signed-off-by: Michael Carlstrom <[email protected]>

* Try extending the type assert

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to logging_service.py (#1227)

* add types to logging_service

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to duration.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Add newlines for class definintions

Signed-off-by: Michael Carlstrom <[email protected]>

* update type alias name

Signed-off-by: Michael Carlstrom <[email protected]>

* Remove newline

Signed-off-by: Michael Carlstrom <[email protected]>

* Merge?

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix failed merge

Signed-off-by: Michael Carlstrom <[email protected]>

* Update to use Protocols

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix import error

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to time.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Linty

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>

* Revert "Add types to TypeHash and moved away from __slots__ usage (#1232)" (#1243)

This reverts commit b06baef.

Signed-off-by: Michael Carlstrom <[email protected]>

* Add back Type hash __slots__ and add test cases. (#1245)

* Add types to TypeHash and add test cases

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to context.py (#1240)

Signed-off-by: Michael Carlstrom <[email protected]>

* fix pub and sub

Signed-off-by: Michael Carlstrom <[email protected]>

* Update LifecyclePublisher

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix docstring

Signed-off-by: Michael Carlstrom <[email protected]>

* serialization generic

Signed-off-by: Michael Carlstrom <[email protected]>

* serialization generic

Signed-off-by: Michael Carlstrom <[email protected]>

* Update type_support.py

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: SnIcK <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Co-authored-by: SnIcK <[email protected]>
Co-authored-by: Chris Lalancette <[email protected]>
Co-authored-by: Shane Loretz <[email protected]>
sloretz added a commit that referenced this pull request Aug 5, 2024
* First draft of generics

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix Generic

Signed-off-by: Michael Carlstrom <[email protected]>

* Add legacy

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix import order

Signed-off-by: Michael Carlstrom <[email protected]>

* fix import order

Signed-off-by: Michael Carlstrom <[email protected]>

* Add Docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

* Add Docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

* Add generics support to Node

Signed-off-by: Michael Carlstrom <[email protected]>

* Update type_support.py

Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to expand_topic_name (#1238)

Signed-off-by: Michael Carlstrom <[email protected]>

* Creates Enum wrapper for ClockType and ClockChange (#1235)

* Testing out Enum wrapper for ClockType

* convert to rcl_clock_type_t

* Update create_time_point

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types (#1231)

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to exceptions.py (#1241)

* Add types to exception

* Add type checking guard

* Fix NotInitializedException

* Add missing defualt

Signed-off-by: Michael Carlstrom <[email protected]>

* added python3-yaml (#1242)

Signed-off-by: SnIcK <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to duration.py (#1233)

* Add types to logging_service.py (#1227)

* add types to logging_service

* Add types to duration.py

* Add newlines for class definintions

* update type alias name

* Update to use Protocols

Signed-off-by: Michael Carlstrom <[email protected]>

* Add Static Typing to Validate files (#1230)

* Add types to validate files

Signed-off-by: Michael Carlstrom <[email protected]>

* remove type annotations from docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

* removed other type annotated docstrings

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to TypeHash and moved away from __slots__ usage (#1232)

* Add types to TypeHash and moved away from __slots__ usage

Signed-off-by: Michael Carlstrom <[email protected]>

* remove docstring types

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>

* Time.py Types (#1237)

* Start typing time.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Testing out Enum wrapper for ClockType

Signed-off-by: Michael Carlstrom <[email protected]>

* convert to rcl_clock_type_t

Signed-off-by: Michael Carlstrom <[email protected]>

* Undo Change to time_point.cpp

Signed-off-by: Michael Carlstrom <[email protected]>

* Update create_time_point

Signed-off-by: Michael Carlstrom <[email protected]>

* Lint fixes

Signed-off-by: Michael Carlstrom <[email protected]>

* Add debug message

Signed-off-by: Michael Carlstrom <[email protected]>

* Remove test file

Signed-off-by: Michael Carlstrom <[email protected]>

* Try extending the type assert

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to logging_service.py (#1227)

* add types to logging_service

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to duration.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Add newlines for class definintions

Signed-off-by: Michael Carlstrom <[email protected]>

* update type alias name

Signed-off-by: Michael Carlstrom <[email protected]>

* Remove newline

Signed-off-by: Michael Carlstrom <[email protected]>

* Merge?

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix failed merge

Signed-off-by: Michael Carlstrom <[email protected]>

* Update to use Protocols

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix import error

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to time.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Linty

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>

* Revert "Add types to TypeHash and moved away from __slots__ usage (#1232)" (#1243)

This reverts commit b06baef.

Signed-off-by: Michael Carlstrom <[email protected]>

* Add back Type hash __slots__ and add test cases. (#1245)

* Add types to TypeHash and add test cases

Signed-off-by: Michael Carlstrom <[email protected]>

* Add types to context.py (#1240)

Signed-off-by: Michael Carlstrom <[email protected]>

* fix pub and sub

Signed-off-by: Michael Carlstrom <[email protected]>

* Update LifecyclePublisher

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix docstring

Signed-off-by: Michael Carlstrom <[email protected]>

* Start implementation

Signed-off-by: Michael Carlstrom <[email protected]>

* Ungeneric?

Signed-off-by: Michael Carlstrom <[email protected]>

* Stuff

Signed-off-by: Michael Carlstrom <[email protected]>

* serialization generic

Signed-off-by: Michael Carlstrom <[email protected]>

* serialization generic

Signed-off-by: Michael Carlstrom <[email protected]>

* Update type_support.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Client Service Generic Implementation

Signed-off-by: Michael Carlstrom <[email protected]>

* Fix debug relative import

Signed-off-by: Michael Carlstrom <[email protected]>

* Update imports

Signed-off-by: Michael Carlstrom <[email protected]>

* Add generics to node.py

Signed-off-by: Michael Carlstrom <[email protected]>

* Update import order

Signed-off-by: Michael Carlstrom <[email protected]>

* Remove double bracket

Signed-off-by: Michael Carlstrom <[email protected]>

---------

Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: Michael Carlstrom <[email protected]>
Signed-off-by: SnIcK <[email protected]>
Co-authored-by: SnIcK <[email protected]>
Co-authored-by: Chris Lalancette <[email protected]>
Co-authored-by: Shane Loretz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants