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

Erroneous mypy specifications #70

Closed
artivis opened this issue Jul 17, 2019 · 2 comments · Fixed by #74
Closed

Erroneous mypy specifications #70

artivis opened this issue Jul 17, 2019 · 2 comments · Fixed by #74
Labels
bug Something isn't working

Comments

@artivis
Copy link
Contributor

artivis commented Jul 17, 2019

Edit:
I've been using import_message_from_namespaced_type wrong due to misleading erroneous mypy specifications

def import_message_from_namespaced_type(message_type: NamespacedType)

Leaving this issue open until the specification get fixed.

Original:

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • source
  • Version or commit hash:
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • rclpy

Steps to reproduce issue

from rosidl_parser.definition import NamespacedType
from rosidl_runtime_py.import_message import import_message_from_namespaced_type

message = import_message_from_namespaced_type(
            NamespacedType(['std_msgs', 'msg'], 'Bool'))

Expected behavior

Imports a std_msgs/msg/Bool

Actual behavior

Crash

AttributeError: 'NamespacedType' object has no attribute 'value_type'

Additional information

Crash comes from import_message_from_namespaced_type which expects a NamespacedType for input arg. NamespacedType expects as input args Iterable[str], str.

NamespacedType has base AbstractNestableType whereas the '__slots__' value_type comes from AbstractNestedType. Am I missing something or is it a bug ?

artivis added a commit to artivis/rosidl_python that referenced this issue Jul 17, 2019
  Fix ros2#70.

Signed-off-by: artivis <jeremie.deray@canonical.com>
@artivis artivis changed the title NamespacedType does not have a 'value' member Erroneous mypy specifications Jul 17, 2019
@dirk-thomas
Copy link
Member

I would guess the annotation is just wrong. This is how it is being used:

if isinstance(rosidl_type.value_type, NamespacedType):
field_elem_type = import_message_from_namespaced_type(rosidl_type)

Maybe @mikaelarguedas can comment since he wrote this in #33.

@mikaelarguedas
Copy link
Member

Yeah that's definitely a bug. I must have mixed up the types when rebasing/updating #33.

See #74 for a fix making the function behave as specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants