Skip to content

Update parameters typing to leverage recursive types #443

Open
@christophebedard

Description

@christophebedard

Looks like recursive types are supported by mypy now: python/mypy#731.

  1. There's a TODO here:
    # TODO(sloretz) Recursive type when mypy supports them python/mypy#731
    _SomeParametersDict = Mapping[SomeParameterName, Any]
    SomeParametersDict = Mapping[SomeParameterName, Union[SomeParameterValue, _SomeParametersDict]]
    • Update the code to leverage recursive types and remove the TODO.
  2. There's also a comment below that mentions "(flattened to avoid having a recursive type)," which could therefore probably also be updated, although I'm not quite sure what to do there:
    # Normalized (flattened to avoid having a recursive type) parameter dict
    ParametersDict = Dict[ParameterName, ParameterValue]
    • I'm not exactly sure what it refers to. However, for this one, we could probably remove "(flattened to avoid having a recursive type)" from the comment and leave the code as-is.
  3. Finally, there are a few references to "making/appeasing mypy" in launch_ros/utilities/normalize_parameters.py. Perhaps that could be revisited to see if we can simplify it. # type: comments could also be updated to the more modern type annotations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions