py_trees icon indicating copy to clipboard operation
py_trees copied to clipboard

create_behaviour_from_function spec'd to return `Any`

Open jbcpollak opened this issue 3 years ago • 1 comments

calling create_behaviour_from_function like this:

        def update(self: py_trees.behaviour.Behaviour) -> py_trees.common.Status:
                return py_trees.common.Status.SUCCESS

        return py_trees.meta.create_behaviour_from_function(
            update
        )(name='Has More To Do')

results in this error from my_py: error: Returning Any from function declared to return "Behaviour"

Looking at how create_behaviour_from_function uses the type function, I suspect this is more a mypy issue than py-trees, but it might be nice to explicitly declare the fuction return a Behavior

jbcpollak avatar Jun 01 '21 15:06 jbcpollak

came across another example that causes the same error:

return py_trees.behaviours.Failure()

results in:

error: Returning Any from function declared to return "Behaviour"

jbcpollak avatar Jun 02 '21 16:06 jbcpollak

def create_behaviour_from_function(
    func: typing.Callable[[typing.Any,], common.Status],
    module: typing.Optional[str] = None
):
) -> "typing.Type[behaviour.Behaviour]"

in #380.

stonier avatar Jan 18 '23 09:01 stonier